import store from "../store/index";
import axios from "axios";

let baseurl = import.meta.env.VITE_BASEURL;
const uploadUrl = `${baseurl}cos/upload`;

axios.interceptors.response.use(
  function (response) {
    return response;
  },
  function (error) {
    return Promise.reject(error);
  }
);
export const $http = function (url, data) {
  return axios({
    method: data ? "post" : "get",
    url: baseurl + url,
    data: {
      ...data,
      loginAccountId: localStorage.loginAccountId,
    },
    withCredentials: true,
  });
};

export default { baseurl, uploadUrl, $http };
