使用fetch时:

  fetch(REQUEST_URL, {
      method: 'get',
      dataType: 'json',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json'
      }
    })
    .then((response) => 
      {
        response.json() // << This is the problem
      })
    .then((responseData) => { // responseData = undefined

        console.log(responseData);
     });
     }).catch(function(err) {
        console.log(err);
      })
     .done();

以下作品很管用,你知道为什么吗

    JSON.parse(response._bodyText)

推荐答案

链接响应应该更像这样,特别是response.json部分.那你应该在console.log里拿到Object分.

.then(response => response.json())
.then(response => {

    console.log(response)

}

React-native相关问答推荐

在AWS-Amplify js v6中检索原始的accesToken和idToken

Reaction-Native-pdf文件不是PDF格式或已损坏

FlatList 总是增长到 100% 高度

无法设置文本输入参考

错误:HostFunction 中的异常: Malformed calls from JS: field sizes are different. In an Animated View

Javascript setTimeout 立即在 React Native 中运行

为什么会出现此错误:Invariant Violation: Cannot update during an existing state transition

ReactJS toLowerCase 不是一个函数

如何在react-native中淡化视图的边缘?

用hooks钩子react context上下文防止重新渲染

如何启用 stacktrace react-native run-android 命令?

命令失败:gradlew.bat installDebug error whenever installing dependencies like navigation, firebase, icons etc in React-Native

React native Refresh 有效,但下一次调用仍使用最后一个令牌

React Native 无法读取 index.android.delta

在 Android React Native 应用程序中正确使用 Intl

如何将捕获的图像与 react-native-camera 一起使用

您将如何在 Alert 中模拟onPress?

zoom 到指定的标记 react-native-maps

React本机IOS,当TextInput获得焦点时,按钮按下不注册

Expo在使用Windows 10的android模拟器上运行