You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
364 B
15 lines
364 B
3 years ago
|
/* Custom axios instance that adds the token to the headers, if existent */
|
||
|
const axios = require("axios");
|
||
|
const UserService = require("./UserService");
|
||
|
|
||
|
axios.interceptors.request.use(function (config) {
|
||
|
const token = UserService.getToken();
|
||
|
|
||
|
if (token) {
|
||
|
config.headers.Authorization = "Bearer " + token;
|
||
|
}
|
||
|
return config;
|
||
|
});
|
||
|
|
||
|
export default axios;
|