fjc0k / taro-axios

在 Taro 中使用 axios。
https://www.npmjs.com/package/taro-axios
MIT License
139 stars 8 forks source link

在支付宝和百度下会报错 #7

Closed honlyHuang closed 5 years ago

honlyHuang commented 5 years ago
// taro 信息
 Taro v1.3.9
  Taro CLI 1.3.9 environment info:
    System:
      OS: macOS High Sierra 10.13.6
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
      Yarn: 1.15.2 - ~/.nvm/versions/node/v10.13.0/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
    npmPackages:
      @tarojs/async-await: ^1.3.11 => 1.3.11
      @tarojs/cli: 1.3.11 => 1.3.11
      @tarojs/components: 1.3.11 => 1.3.11
      @tarojs/plugin-babel: 1.3.11 => 1.3.11
      @tarojs/plugin-csso: 1.3.11 => 1.3.11
      @tarojs/plugin-uglifyjs: 1.3.11 => 1.3.11
      @tarojs/router: 1.3.11 => 1.3.11
      @tarojs/taro: 1.3.11 => 1.3.11
      @tarojs/taro-alipay: 1.3.11 => 1.3.11
      @tarojs/taro-h5: 1.3.11 => 1.3.11
      @tarojs/taro-swan: 1.3.11 => 1.3.11
      @tarojs/taro-tt: 1.3.11 => 1.3.11
      @tarojs/taro-weapp: 1.3.11 => 1.3.11
      @tarojs/webpack-runner: 1.3.11 => 1.3.11
      nerv-devtools: ^1.4.3 => 1.4.3
      nervjs: ^1.4.3 => 1.4.3
    npmGlobalPackages:
      typescript: 3.3.3
// 报错信息
index.js:545 Uncaught (in promise) Error: Network Error
    at createError (index.js:545)
    at index.js:1528
    at <anonymous>
fjc0k commented 5 years ago

我这儿用支付宝的测试了一下,当请求数据返回的状态码不是 200 时,如 201,Taro.request 都会报错(其实是 my.request 报错),然而微信下,网页下,则不存在这个问题。

我觉得应该在 Taro 层面抹平这种差异。

image

fjc0k commented 5 years ago

补充,真机上,支付宝对返回 201 的请求没有报错。

fjc0k commented 5 years ago

经测试,百度下表现同微信。

fjc0k commented 5 years ago

@honlyHuang 发布了新版本,安装试一下,给个反馈。https://github.com/fjc0k/taro-axios/commit/5987c7637cf9bcc599f6b3304d75b485acee3ade