import axios from 'axios';
const instace = axios.create({
baseURL: 'https://internal.takehr.cn',
timeout: 5000,
});
instace.interceptors.request.use(
config => {
console.log('config', config);
return config;
},
err => {
return Promise.reject(err);
},
);
instace.interceptors.response.use(
response => {
return response;
},
err => {
return Promise.reject(err);
},
);
const callapi = (method = 'GET', url, data = {}, customHeaders = {}) => {
return instace({
method,
url,
params: method === 'GET' ? data : {},
data: method === 'POST' ? data : {},
...customHeaders,
});
};
export const getapi = (url, data, customHeaders) => callapi('GET', url, data, customHeaders);
export const postapi = (url, data, customHeaders) => callapi('POST', url, data, customHeaders);