| | |
| | | |
| | | // 前置拦截器(发起请求之前的拦截) |
| | | instance.interceptors.request.use((config: AxiosRequestConfig) => { |
| | | console.log('sss',config) |
| | | config.headers && (config.headers['Authorization'] = getToken()) |
| | | const controller = new AbortController() |
| | | config.signal = controller.signal |
| | |
| | | instance.interceptors.response.use( |
| | | (response: AxiosResponse) => { |
| | | const { data, status } = response |
| | | console.log('返回结果',data) |
| | | const { message } = data |
| | | // 请求正常时,仅返回需要用到的 data 信息即可 |
| | | if (message==='SUCCESS') return data.data |
| | |
| | | ajaxPatch |
| | | } |
| | | |
| | | // export default instance |