123456789101112131415161718192021222324252627282930313233343536373839 |
- import axios from "axios";
- // 创建实例
- // Set config defaults when creating the instance
- const instance = axios.create({
- baseURL: 'https://official.webapi.bicredit.xin/api/',//直接使用博客链接
- timeout: 2500,
- });
- // 添加请求拦截器
- instance.interceptors.request.use((config) => {
- // 在发送请求之前做些什么
- console.log('config', config);
- return config;
- }, function (error) {
- // 对请求错误做些什么
- return Promise.reject(error);
- });
- // 添加响应拦截器
- instance.interceptors.response.use((response) => {
- // 对响应数据做点什么
- console.log('response', response);
- // const {
- // config,
- // data,
- // headers,
- // request,
- // status,
- // statusText
- // } = response
- return response;
- }, function (error) {
- // 对响应错误做点什么
- return Promise.reject(error);
- });
- export default instance
|