Skip to content

Commit 6106e50

Browse files
author
zhigang.li
committed
优化api请求的错误收集
1 parent 8552ce1 commit 6106e50

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Diff for: src/libs/axios.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,16 @@ class HttpRequest {
5151
return { data, status }
5252
}, error => {
5353
this.destroy(url)
54-
addErrorLog(error.response)
54+
let errorInfo = error.response
55+
if (!errorInfo) {
56+
const { request: { statusText, status }, config } = JSON.parse(JSON.stringify(error))
57+
errorInfo = {
58+
statusText,
59+
status,
60+
request: { responseURL: config.url }
61+
}
62+
}
63+
addErrorLog(errorInfo)
5564
return Promise.reject(error)
5665
})
5766
}

0 commit comments

Comments
 (0)