【发布时间】:2015-10-20 12:52:22
【问题描述】:
使用 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()
标签: react-native