Skip to content

Instantly share code, notes, and snippets.

@dapperAuteur
Created March 19, 2018 23:42
Show Gist options
  • Save dapperAuteur/cfd4a8af3891dfc2e4b156e3dddd6d4f to your computer and use it in GitHub Desktop.
Save dapperAuteur/cfd4a8af3891dfc2e4b156e3dddd6d4f to your computer and use it in GitHub Desktop.
passing the token in the header to communicate user is authorized
export async function updatePalabra(p, pObj) {
console.log(`${APIURL}${p}${pObj._id}`);
console.log(pObj);
let token = `Bearer ${pObj.token}`;
console.log(token);
return fetch(`${APIURL}${p}${pObj._id}`, {
method: 'put',
headers: new Headers({
'Content-Type': 'application/json',
'Authorization': token
}),
body: JSON.stringify({ ...pObj })
})
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment