Skip to content

Commit

Permalink
chore: upgrade axios to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
glorat committed Jan 19, 2024
1 parent 03f3a35 commit e3dc582
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
25 changes: 13 additions & 12 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/jest": "^26.0.24",
"@types/lodash": "^4.14.178",
"@types/marked": "^4.0.1",
"axios": "^0.21.4",
"axios": "1.6.0",
"core-js": "^3.20.1",
"csv-stringify": "^6.0.5",
"firebase": "^10.7.1",
Expand Down
23 changes: 11 additions & 12 deletions client/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SingleFXConversion, SingleFXConverter} from '../lib/fx'
import axios, {AxiosRequestConfig} from 'axios'
import axios, {AxiosRequestConfig, InternalAxiosRequestConfig} from 'axios'
import {
AccountDTO,
AllState, AssetDTO,
Expand Down Expand Up @@ -85,16 +85,17 @@ export const storeKey: InjectionKey<VuexStore<MyState>> = Symbol('vuex-key')


export default store(function (/* { ssrContext } */) {
let requestPreprocessor = async (config:AxiosRequestConfig):Promise<AxiosRequestConfig> => {
let requestPreprocessor = async (config:InternalAxiosRequestConfig):Promise<InternalAxiosRequestConfig> => {
return config;
}

axios.interceptors.request.use(function (config) {
return requestPreprocessor(config);
}, function (error) {
// Do something with request error
return Promise.reject(error);
});
axios.interceptors.request.use(
config => {
return requestPreprocessor(config)
},
error => {
return Promise.reject(error);
}
);

axios.interceptors.response.use(res => res, function (error) {
if (error.response.status === 401) {
Expand Down Expand Up @@ -334,9 +335,7 @@ export default store(function (/* { ssrContext } */) {

requestPreprocessor = async (config) => {
const token = await getToken();
config.headers.common = {
Authorization: `Bearer ${token}` // send the access token through the 'Authorization' header
};
config.headers['Authorization'] = `Bearer ${token}`;
return config;
}

Expand Down

0 comments on commit e3dc582

Please sign in to comment.