Files
dancefinder-app/utils/graph-client/middleware.js
T
2019-01-15 13:21:24 +01:00

16 lines
417 B
JavaScript

module.exports = {
includeCredentials: (tokenFn) => {
return ({options}, next) => {
if (!options.headers) {
options.headers = {}; // Create the headers object if needed.
}
const token = tokenFn();
if (token) {
options.headers['Authorization'] = 'Bearer ' + tokenFn();
}
options.credentials = 'same-origin'; // eslint-disable-line
next();
}
},
};