Skip to content

Instantly share code, notes, and snippets.

@aindong
Created August 19, 2016 13:25
Show Gist options
  • Save aindong/20be7b70e02dbfd99ae2d490c8d65117 to your computer and use it in GitHub Desktop.
Save aindong/20be7b70e02dbfd99ae2d490c8d65117 to your computer and use it in GitHub Desktop.
Generic Fetch option
import {
getAuthToken
} from './token.js';
export const fetchOpts = (method, body = null) => {
return Object.assign({}, {
method,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': `Bearer ${getAuthToken()}`
}
}, body ? {
body: JSON.stringify(body)
} : {});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment