描述
简单的对axios进行封装,可扩展
代码内容
import axios from "axios";
// 请求拦截
axios.interceptors.request.use(
async (config) => {
return config;
},
(error) => {
return Promise.reject();
}
);
// 返回拦截
axios.interceptors.response.use(
(response) => {
return response;
},
(error) => {
return Promise.resolve(error.response);
}
);
// 发送请求
async function service(
method,
url,
params,
typ