chore: format project automatically before starting dev server
This commit is contained in:
+7
-16
@@ -1,6 +1,5 @@
|
||||
import axios from 'axios';
|
||||
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL || 'https://api.example.com',
|
||||
timeout: 15000,
|
||||
@@ -9,32 +8,26 @@ const api = axios.create({
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
api.interceptors.request.use(
|
||||
(config) => {
|
||||
const token =
|
||||
typeof window !== 'undefined' ? window.localStorage.getItem('rm-auth-token') : null;
|
||||
config => {
|
||||
const token = typeof window !== 'undefined' ? window.localStorage.getItem('rm-auth-token') : null;
|
||||
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
// console.log('[API request]', config.method?.toUpperCase(), config.url);
|
||||
// console.log('[API request]', config.method?.toUpperCase(), config.url);
|
||||
|
||||
return config;
|
||||
|
||||
|
||||
},
|
||||
(error) => Promise.reject(error)
|
||||
error => Promise.reject(error),
|
||||
);
|
||||
|
||||
|
||||
api.interceptors.response.use(
|
||||
(response) => response,
|
||||
response => response,
|
||||
|
||||
(error) => {
|
||||
error => {
|
||||
if (error.response) {
|
||||
|
||||
const status = error.response.status;
|
||||
|
||||
if (status === 401) {
|
||||
@@ -50,10 +43,8 @@ api.interceptors.response.use(
|
||||
// TODO: Display a network connection error.
|
||||
}
|
||||
|
||||
|
||||
return Promise.reject(error);
|
||||
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export default api;
|
||||
|
||||
Reference in New Issue
Block a user