无法通过我的 GET 响应接收数据
Cannot receive data through my GET response
我正在将数据从我的数据库发送到我的 React-native 应用程序,但是当我从我的 GET 请求收到响应时,我无法从响应中取出我的数据。
我尝试过 JSON.stringify
、JSON.parse
、放入响应[0]、response.name(我响应中的对象之一)等
alert(JSON.stringify(response));
This is how my current response looks like.
我的回复主体有 4 个对象,_key、姓名、电子邮件和学校。我希望能够从我的回复中查看并保存所有这些对象。
如果您正在使用提取和调用:
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))
我正在将数据从我的数据库发送到我的 React-native 应用程序,但是当我从我的 GET 请求收到响应时,我无法从响应中取出我的数据。
我尝试过 JSON.stringify
、JSON.parse
、放入响应[0]、response.name(我响应中的对象之一)等
alert(JSON.stringify(response));
This is how my current response looks like.
我的回复主体有 4 个对象,_key、姓名、电子邮件和学校。我希望能够从我的回复中查看并保存所有这些对象。
如果您正在使用提取和调用:
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))