taro RN uploadFile 接口返回的内容不对

w46czmvw  于 5个月前  发布在  其他
关注(0)|答案(2)|浏览(44)

相关平台

React Native

使用框架: React

复现步骤

Taro.uploadFile({
  url,
  filePath,
  success (res) {
    console.log(JSON.stringify(res))
  }
})

期望结果

{
 "filePath": "file:///storage/emuLated/0/Android/data/com.yonyougov.cwy/fiLes/Pictures/IMG_CMP-F9D31AD8E65383238348B177FB8F71.jpeg ",
 "name": "file",
 "url": "/abf/app/attachment/upLoadFiLes"
}

实际结果

{
  "type": "default",
  "status": 200,
  "ok": "true",
  "statusText": "",
  "urt": "...",
  "bodyUsed": "false",
  "_bodyInit": {
  }
}

环境信息

👽 Taro v3.3.11

  Taro CLI 3.3.11 environment info:
    System:
      OS: macOS 11.6
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 15.12.0 - /usr/local/bin/node
      Yarn: 1.22.10 - ~/.nvm/versions/node/v15.12.0/bin/yarn
      npm: 7.6.3 - ~/.nvm/versions/node/v15.12.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.3.12 => 3.3.12
      @tarojs/components: 3.3.12 => 3.3.12
      @tarojs/mini-runner: 3.3.12 => 3.3.12
      @tarojs/react: 3.3.12 => 3.3.12
      @tarojs/runtime: 3.3.12 => 3.3.12
      @tarojs/taro: 3.3.12 => 3.3.12
      @tarojs/webpack-runner: 3.3.12 => 3.3.12
      babel-preset-taro: 3.3.12 => 3.3.12
      eslint-config-taro: 3.3.12 => 3.3.12
      react: ^17.0.2 => 17.0.2
      react-native: ^0.66.1 => 0.66.1
    npmGlobalPackages:
      typescript: 4.2.3
x8diyxa7

x8diyxa71#

临时解决方案

res.json().then(response => console.log(response))
5ssjco0h

5ssjco0h2#

success回调参数中,没有data字段

相关问题