nestjs rewrite

This commit is contained in:
popovspiridon99
2025-08-01 11:08:33 +09:00
parent 1f9a3a8e03
commit 145827ab6d
28 changed files with 1220 additions and 623 deletions

View File

@ -0,0 +1,27 @@
import axios, { ResponseType } from 'axios';
import { useAuthStore } from '../store/auth';
const axiosInstance = axios.create();
axiosInstance.interceptors.request.use(
(config) => {
const token = useAuthStore.getState().token;
if (token) {
config.headers['Authorization'] = `Bearer ${token}`;
}
return config;
},
(error) => {
return Promise.reject(error);
}
);
export const fetcher = (url: string, baseURL?: string, responseType?: ResponseType) => axiosInstance.get(url, {
baseURL: baseURL || import.meta.env.VITE_API_NEST_URL,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
responseType: responseType ? responseType : "json"
}).then(res => res.data)
export default axiosInstance;