fixed composable path error
This commit is contained in:
+15
-14
@@ -1,13 +1,13 @@
|
||||
import axiosOriginal from "axios";
|
||||
import { useAuth } from "~/composables/api/auth/useAuth";
|
||||
import { API_ENDPOINTS } from "~/constants";
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
|
||||
const config = useRuntimeConfig();
|
||||
const { logout, token } = useAuth();
|
||||
|
||||
const axios = axiosOriginal.create({
|
||||
baseURL: config.public.API_BASE_URL
|
||||
baseURL: config.public.API_BASE_URL,
|
||||
});
|
||||
|
||||
axios.interceptors.request.use((config) => {
|
||||
@@ -21,21 +21,22 @@ export default defineNuxtPlugin(() => {
|
||||
return config;
|
||||
});
|
||||
|
||||
axios.interceptors.response.use((response) => {
|
||||
return response;
|
||||
}, function(error) {
|
||||
axios.interceptors.response.use(
|
||||
(response) => {
|
||||
return response;
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401) {
|
||||
logout();
|
||||
}
|
||||
|
||||
if (error.status === 401) {
|
||||
logout();
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
});
|
||||
);
|
||||
|
||||
return {
|
||||
provide: {
|
||||
axios
|
||||
}
|
||||
axios,
|
||||
},
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user