import '@/types/Shopee/Shop/Index';
import axios from 'axios';
import fetchAdapter from '@vespaiach/axios-fetch-adapter';
import { SHOPEE_DOMAIN_HOME } from '@/config/api';

const getHeader = () => {
  return {
    accept: 'application/json',
    'af-ac-enc-dat': null,
    'af-ac-enc-sz-token': '',
    'content-type': 'application/json',
  };
};

export const apiShopeeClient = axios.create({
  baseURL: SHOPEE_DOMAIN_HOME,
  responseType: 'json',
  headers: getHeader(),
  adapter: fetchAdapter,
  timeout: 10000,
});

apiShopeeClient.interceptors.response.use((response) => response.data);
apiShopeeClient.interceptors.request.use((request) => {
  request.headers = {
    ...getHeader(),
    ...(request.headers || {}),
  };
  return request;
});
