Commit b7771c00 authored by nick zheng's avatar nick zheng

test: 控制台打印请求信息

parent 11e15ca2
......@@ -73,6 +73,7 @@ service.interceptors.request.use(
service.interceptors.response.use(
(response: AxiosResponse) => {
console.log('response', response)
if (response.status === 200) {
return response.data
}
......@@ -80,6 +81,7 @@ service.interceptors.response.use(
throw new Error(response.status.toString())
},
(error) => {
console.log('error', error)
const response = error.response
// 处理响应错误
......@@ -100,6 +102,7 @@ function http<T>(
) {
/* 请求成功处理函数 */
const successHandler = (res: Response<T>): Promise<Response<T>> | Response<T> => {
console.log('successHandler', res)
if (res.code === 0 || options?.ignoreErrorCheck) return res
if (res.code === -10) {
......@@ -116,6 +119,7 @@ function http<T>(
/* 请求失败处理函数 */
const failHandler = (error: Error) => {
console.log('failHandler', error)
throw new Error(error?.message || 'Error')
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment