feat: input virtual add header request api
This commit is contained in:
@@ -8,16 +8,6 @@ const createClient = (baseURL, withBaseFormat = false) => {
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' }
|
||||
});
|
||||
|
||||
client.interceptors.request.use((config) => {
|
||||
const token = typeof window !== 'undefined' ? localStorage.getItem('token') : null;
|
||||
if (token) {
|
||||
config.headers = config.headers ?? {};
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
return config;
|
||||
});
|
||||
|
||||
if (withBaseFormat) {
|
||||
client.interceptors.response.use(
|
||||
(response) =>
|
||||
|
||||
Reference in New Issue
Block a user