// service 统一出口
import HealthRequest from './requet'
import { BASE_URL, TIMEOUT } from './requet/config'
const healthRequest = new HealthRequest({
baseURL: BASE_URL,
timeout: TIMEOUT,
interceptors: {
requestInterceptor: (config) => {
// 携带token拦截
const token = ''
if (token) {
// config.headers.Authorization = token
config.headers.Authorization = `Bearer ${token}`
}
console.log('请求成功的拦截')
return config
},
requestInterceptorCatch: (err) => {
console.log('请求拦截失败')
return err
},
responseInterceptor: (res) => {
console.log('响应成功的拦截')
return res
},
responseInterceptorCatch: (err) => {
console.log('响应拦截失败')
return err
}
}
})
export default healthRequest