import { InternalAxiosRequestConfig } from "axios";
import Cookies from "js-cookie";
import { COOKIE_KEYS } from "../lib/shared/cookies";

export const requestInterceptor = (config: InternalAxiosRequestConfig) => {
  const token = Cookies.get(COOKIE_KEYS.access_token);

  if (token) {
    config.headers.Authorization = `Bearer ${token}`;
  }

  return config;
};

export const requestErrorHandler = (error: any) => {
  return Promise.reject(error);
};
