Commit 2669b119 authored by nick zheng's avatar nick zheng

Merge branch 'beta' into 'master'

test: 控制台打印请求信息

See merge request !127
parents 1f07657e b7771c00
...@@ -73,6 +73,7 @@ service.interceptors.request.use( ...@@ -73,6 +73,7 @@ service.interceptors.request.use(
service.interceptors.response.use( service.interceptors.response.use(
(response: AxiosResponse) => { (response: AxiosResponse) => {
console.log('response', response)
if (response.status === 200) { if (response.status === 200) {
return response.data return response.data
} }
...@@ -80,6 +81,7 @@ service.interceptors.response.use( ...@@ -80,6 +81,7 @@ service.interceptors.response.use(
throw new Error(response.status.toString()) throw new Error(response.status.toString())
}, },
(error) => { (error) => {
console.log('error', error)
const response = error.response const response = error.response
// 处理响应错误 // 处理响应错误
...@@ -100,6 +102,7 @@ function http<T>( ...@@ -100,6 +102,7 @@ function http<T>(
) { ) {
/* 请求成功处理函数 */ /* 请求成功处理函数 */
const successHandler = (res: Response<T>): Promise<Response<T>> | Response<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 === 0 || options?.ignoreErrorCheck) return res
if (res.code === -10) { if (res.code === -10) {
...@@ -116,6 +119,7 @@ function http<T>( ...@@ -116,6 +119,7 @@ function http<T>(
/* 请求失败处理函数 */ /* 请求失败处理函数 */
const failHandler = (error: Error) => { const failHandler = (error: Error) => {
console.log('failHandler', error)
throw new Error(error?.message || '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