import axios from 'axios';

const request = axios.create({
  baseURL: window.VITE_BASE_API,
  timeout: 10000
});

// request拦截器
request.interceptors.request.use((config) => {
  return config;
});

request.interceptors.response.use(
  function (res) {
    return res.data;
  },
  function (error) {
    return new Error(error);
  }
);

const cityGisRequest = axios.create({
  baseURL: window.VITE_CityGIS_API,
  timeout: 10000
});
cityGisRequest.interceptors.request.use((config) => {
  return config;
});

cityGisRequest.interceptors.response.use(
  function (res) {
    return res.data;
  },
  function (error) {
    return new Error(error);
  }
);

export { request, cityGisRequest };
