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.
30 lines
655 B
30 lines
655 B
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;
|
|
});
|