import axios from "axios";
import Cookies from "js-cookie";

const baseURL = "http://38.47.180.165:8802";

const refreshToken = Cookies.get("refresh_token");

const axiosInterceptorInstance = axios.create({
  baseURL,
  headers: {
    "content-type": "application/json",
  },
});

// Request interceptor
axiosInterceptorInstance.interceptors.request.use(
  (config) => {
    const accessToken = Cookies.get("access_token");
    if (accessToken) {
      if (config.headers)
        config.headers.Authorization = "Bearer " + accessToken;
    }
    return config;
  },
  (error) => {
    return Promise.reject(error);
  },
);

// Response interceptor


export default axiosInterceptorInstance;
