import axios from "axios";
import Cookies from "js-cookie";
import "react-toastify/dist/ReactToastify.css";

const BASE_URL = process.env.NEXT_PUBLIC_API_URL;

const token = Cookies.get("access_token");

const api = axios.create({
  baseURL: BASE_URL,
  "X-CSRF-Token": "",
  headers: {
    "Content-Type": "application/json",
    Authorization: token ? `Bearer ${token}` : "",
  },
});

api.interceptors.response.use(
  (response) => {
    return response.data;
  },
  (error) => {
    return Promise.reject(error);
  }
);

export default api;
