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 500错误无法拦截 #11518

Closed
nanhupatar opened this issue Mar 27, 2022 · 12 comments
Closed

Taro.request 500错误无法拦截 #11518

nanhupatar opened this issue Mar 27, 2022 · 12 comments
Labels
duplicate This issue or pull request already exists F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x

Comments

@nanhupatar
Copy link

相关平台

H5

复现仓库

https://github.com/TigerHee/taro-request
浏览器版本: Chrome 62
使用框架: React

复现步骤

Taro.request 500错误,直接走的是fail,和小程序不同。小程序类似404,500,502等请求都会success

期望结果

如何保持一致

实际结果

h5拦截器与小程序不一致

环境信息

  Taro CLI 3.4.2 environment info:
    System:
      OS: macOS 10.14.6
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
      Yarn: 1.22.5 - ~/.yarn/bin/yarn
      npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
    npmPackages:
      @tarojs/components: 3.4.2 => 3.4.2 
      @tarojs/mini-runner: 3.4.2 => 3.4.2 
      @tarojs/react: 3.4.2 => 3.4.2 
      @tarojs/router: ^3.4.3 => 3.4.2 
      @tarojs/runtime: 3.4.2 => 3.4.2 
      @tarojs/taro: 3.4.2 => 3.4.2 
      @tarojs/webpack-runner: 3.4.2 => 3.4.2 
      babel-preset-taro: 3.4.2 => 3.4.2 
      eslint-config-taro: 3.4.2 => 3.4.2 
      react: ^17.0.0 => 17.0.2 
@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Mar 27, 2022
@github-actions
Copy link
Contributor

等待热心的小伙伴解决问题中..., 有一些相关的 issues 可能帮助到你!

Thank you so much!

@nanhupatar
Copy link
Author

@nanhupatar
Copy link
Author

类似错误 #3017

@nanhupatar
Copy link
Author

只要成功接收到服务器返回,无论 statusCode 是多少,都会进入 success 回调。请开发者根据业务逻辑对返回值进行判断。

@nanhupatar
Copy link
Author

只要成功接收到服务器返回,无论 statusCode 是多少,都会进入 success 回调。请开发者根据业务逻辑对返回值进行判断。
https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html

@nanhupatar
Copy link
Author

并且如果是500错误 ,err也无法查看到response的内容

@qing-zhi
Copy link

H5平台 Taro.request 500错误,直接走的是fail,和小程序不同。小程序类似404,500,502等请求都会success

@nanhupatar
Copy link
Author

nanhupatar commented Apr 19, 2022 via email

@moell-peng
Copy link

我使用的 3.4.3 也出现这样的问题,希望小程序和H5触发 success 和 fail 表现一致。

const option = {
    ...
    fail: (res) => {
      console.log(res)
    },
    success: (response) => {
      console.log("success", response)
    }
  }

Taro.request(option)

服务端返回 403 等状态码:
H5: 执行fail
微信小程序: 执行success

@wenxiuYang
Copy link

遇到同样问题, v3.4.11
如 4xx, 5xx 状态码,只能在 Taro.request().fail 拦截,错误信息简陋,无法查看返回信息, 且数据格式 与 success 的回调不同

@ZakaryCode
Copy link
Contributor

duplicate #9983

@ZakaryCode ZakaryCode added the duplicate This issue or pull request already exists label Aug 23, 2022
@taro-bot2 taro-bot2 bot closed this as completed Aug 23, 2022
@az031120103
Copy link

遇到同样的问题,请问解决了没有?

@ZakaryCode ZakaryCode moved this to Done in H5 Apr 10, 2023
@ZakaryCode ZakaryCode added this to H5 Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
Development

No branches or pull requests

6 participants