You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
618 B

import axios from "axios";
// const instance = axios.create({
// baseURL: "http://10.10.10.12:8080/api/v1/",
// });
const instance = axios.create({
baseURL: "https://api.tteld.co/api/v1/",
});
const token: string | null = localStorage.getItem("access");
if (token) {
instance.defaults.headers.common["Authorization"] = `Bearer ${token}`;
}
instance.interceptors.response.use(
(response) => response,
(error) => {
if (error.response && error.response.status === 401) {
localStorage.clear();
window.location.reload();
}
return Promise.reject(error);
}
);
export default instance;