import axios from 'axios';

const service = axios.create({
  baseURL: 'http://localhost:18888/api',
  timeout: 60000,
  headers: {
    'Content-Type': 'application/json',
  },
});
service.interceptors.response.use(
  (response: any) => {
    // 去除响应头中的跨域请求参数
    delete response.headers['access-control-allow-credentials'];
    const { data } = response;
    return Promise.resolve(data);
  },
  async (error: any) => {
    // ElMessage.error(error);
    return Promise.reject(error);
  }
);
export const get = (url: string, params?: object, _object = {}) => {
  return service.get(url, { params, ..._object });
};
export const post = (url: string, params?: object, _object = {}) => {
  return service.post(url, { params, ..._object });
};
