You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_php/public/kefu-assets/libs/http.js

30 lines
655 B

10 months ago
define(["axios"], (axios) => {
const instance = axios.create({
timeout: 10000
});
instance.interceptors.response.use((response) => {
if (response.data.code != 200) {
return Promise.reject(response.data);
}
return response.data;
}, (err) => {
return Promise.reject(err);
});
const http = {
get(path, params, options) {
return instance.get(path, {
...options,
params,
});
},
post(path, data, options) {
return instance.post(path, data, options);
}
};
return http;
});