mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-26 21:15:15 +00:00
Fix axios error introduced in last updates
This commit is contained in:
parent
2b6315966b
commit
19a479ef2b
|
@ -1,5 +1,5 @@
|
||||||
import { useBotStore } from '@/stores/ftbotwrapper';
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
||||||
import axios from 'axios';
|
import axios, { AxiosHeaders } from 'axios';
|
||||||
import { UserService } from './userService';
|
import { UserService } from './userService';
|
||||||
|
|
||||||
export function useApi(userService: UserService, botId: string) {
|
export function useApi(userService: UserService, botId: string) {
|
||||||
|
@ -10,15 +10,18 @@ export function useApi(userService: UserService, botId: string) {
|
||||||
});
|
});
|
||||||
// Sent auth headers interceptor
|
// Sent auth headers interceptor
|
||||||
api.interceptors.request.use(
|
api.interceptors.request.use(
|
||||||
(config) => {
|
(request) => {
|
||||||
const custconfig = config;
|
|
||||||
const token = userService.getAccessToken();
|
const token = userService.getAccessToken();
|
||||||
// Append token to each request
|
try {
|
||||||
if (token) {
|
if (token) {
|
||||||
// Merge custconfig dicts
|
request.headers = request.headers as AxiosHeaders;
|
||||||
custconfig.headers = { ...config.headers, ...{ Authorization: `Bearer ${token}` } };
|
// Append token to each request
|
||||||
|
request.headers.set('Authorization', `Bearer ${token}`);
|
||||||
}
|
}
|
||||||
return custconfig;
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
return request;
|
||||||
},
|
},
|
||||||
(error) => Promise.reject(error),
|
(error) => Promise.reject(error),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user