【问题标题】:Cannot receive data through my GET response无法通过我的 GET 响应接收数据
【发布时间】:2019-06-23 19:50:35
【问题描述】:

我正在将数据从我的数据库发送到我的 React-native 应用程序,但是当我收到来自我的 GET 请求的响应时,我无法从响应中取出我的数据。

我尝试过使用JSON.stringifyJSON.parse、放入 response[0]、response.name(我的响应中的一个对象)等。

alert(JSON.stringify(response));

This is how my current response looks like.

我的回复正文有 4 个对象,_key、姓名、电子邮件和学校。我希望能够从我的回复中看到并保存所有这些对象。

【问题讨论】:

  • 请发布您的相关代码,以便我们为您提供帮助。很遗憾,此时您的帖子中没有足够的信息。

标签: json react-native get arangodb


【解决方案1】:

如果您正在使用 fetch 和调用:

fetch('http://yourdomain.com', {method: 'GET',})
.then(response => {alert(JSON.stringify(response));)

然后你需要调用第二个.then() 来获取响应的正文:

fetch('http://yourdomain.com', {method: 'GET',})
.then(response => {response.json()})
.then(data => {alert(data)})
.catch(error => console.log(error))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-25
    • 1970-01-01
    • 2015-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多