Skip to content

Commit

Permalink
fix(taro-h5): 响应体无数据时抛错进入reject (#4599)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrReMain authored and luckyadam committed Oct 21, 2019
1 parent 351c0ac commit 84ce3ef
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/taro-h5/src/api/request/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ function _request (options) {
response.headers.forEach((val, key) => {
res.header[key] = val
})
if(!response.ok) {
throw response

This comment has been minimized.

Copy link
@rsnzh

rsnzh Nov 2, 2019

这里抛出异常会导致非200类 响应无法进入正常处理逻辑,我觉得应该由使用者去处理状态,保持与小程序结果是一致

This comment has been minimized.

Copy link
@qianzhaoy

qianzhaoy Nov 4, 2019

已踩坑。更新后。非 200 http code错误捕捉失效,只能在 catch 里再做一次兼容。并且该做法违反 fetch 标准。

}
if (options.responseType === 'arraybuffer') {
return response.arrayBuffer()
}
Expand Down

0 comments on commit 84ce3ef

Please sign in to comment.