Skip to content

Commit

Permalink
feat: revert NervJS#4599, 并参照小程序抹平err时字段
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyo837 committed Oct 3, 2022
1 parent 6add4ff commit 0dd3d41
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/taro-h5/src/api/network/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ function _request (options) {
for (const key of response.headers.keys()) {
res.header[key] = response.headers.get(key)
}
if (!response.ok) {
throw response
}
if (options.responseType === 'arraybuffer') {
return response.arrayBuffer()
}
Expand All @@ -119,9 +116,15 @@ function _request (options) {
return res
})
.catch(err => {
typeof fail === 'function' && fail(err)
const { status, statusText, ...rest} = err
const errRes = {
...rest,
statusCode: status,
errMsg: statusText
}
typeof fail === 'function' && fail(errRes)
typeof complete === 'function' && complete(res)
return Promise.reject(err)
return Promise.reject(errRes)
})
}

Expand Down

0 comments on commit 0dd3d41

Please sign in to comment.