Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taro.request,http状态码非200时,会走到fail方法,且参数没有返回http状态码 #9983

Closed
ruidoc opened this issue Aug 5, 2021 · 5 comments · Fixed by #12605
Labels
E-medium Helper Wanted - Medium F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x

Comments

@ruidoc
Copy link
Contributor

ruidoc commented Aug 5, 2021

相关平台

H5

浏览器版本: Chrome92
使用框架: React

复现步骤

一个普通的post请求,http状态码为422,直接走到fail回调函数里。然后打印回调函数参数error,并没有http的状态码和接口返回的data数据,无法捕获状态码和返回数据

期望结果

返回 httpStatus 和 responseData

实际结果

{
 status: 0
 statusText: ""
}

环境信息

Taro v3.3.1


  Taro CLI 3.3.1 environment info:
    System:
      OS: macOS 11.2.3
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.16.0 - /usr/local/opt/node@14/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 6.14.11 - /usr/local/opt/node@14/bin/npm
    npmPackages:
      @tarojs/components: 3.3.1 => 3.3.2 
      @tarojs/mini-runner: 3.3.1 => 3.3.2 
      @tarojs/react: 3.3.1 => 3.3.2 
      @tarojs/runtime: 3.3.1 => 3.3.2 
      @tarojs/taro: 3.3.1 => 3.3.2 
      @tarojs/webpack-runner: 3.3.1 => 3.3.2 
      babel-preset-taro: 3.3.1 => 3.3.2 
      eslint-config-taro: 3.3.1 => 3.3.2 
      react: ^17.0.0 => 17.0.2 
      taro-ui: ^3.0.0-alpha.10 => 3.0.0-alpha.10 

补充信息

我觉得问题出现,错误对象中目前不包含http状态嘛和响应data,这个在业务中是需要的

@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Aug 5, 2021
@Pancy-max
Copy link

+1

@ssiapp
Copy link

ssiapp commented Dec 15, 2021

+1

@zybieku
Copy link

zybieku commented Jan 11, 2022

h5中使用的是featch 请求,fail返回的对象是ReadableStream,如果需要拿到里面的值 可以使用 err.json().then() 或者 async/await
image

@qing-zhi
Copy link

+1

1 similar comment
@zhouzyc
Copy link

zhouzyc commented May 5, 2022

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-medium Helper Wanted - Medium F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants