Replace Table with responsive Card. Add refresh of token and retry on 401 errors
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
const webAuth = require("../auth").default;
|
||||
|
||||
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();
|
||||
includeCredentials: (uri, options) => {
|
||||
const token = webAuth.idToken();
|
||||
if (token) {
|
||||
options.headers['Authorization'] = 'Bearer ' + token;
|
||||
}
|
||||
},
|
||||
return fetch(uri, options);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user