Skip to content

Instantly share code, notes, and snippets.

@goofballLogic
Created June 4, 2018 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goofballLogic/bbfdc86fbcd5891c89fc055ed8ff3e6b to your computer and use it in GitHub Desktop.
Save goofballLogic/bbfdc86fbcd5891c89fc055ed8ff3e6b to your computer and use it in GitHub Desktop.
function sendJSON( method, data, url ) {
return fetch( url, {
body: data && JSON.stringify( data ),
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json"
}
} );
}
export function saveForLater( person ) {
return sendJSON(
"POST", person,
"http://localhost:3001/for-later"
);
}
export function fetchForLater() {
return fetch( "http://localhost:3001/for-later" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment