【发布时间】:2019-01-20 09:09:15
【问题描述】:
代码:
fetch(`https://api.flickr.com/services/rest/?&method=flickr.photos.search&api_key=++++++++++&tags=obama&format=json&extras=url_m&nojsoncallback=true`, {
method: "GET",
headers : {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
}).then(response => {
console.log(response.json())
})
输出:
Promise {_40: 0, _65: 0, _55: null, _72: null}
【问题讨论】:
-
然后再添加一个:
fetch(...).then(resp => resp.json()).then(data => ...) -
为什么要在
GET请求中发送Content-type标头?您不会使用GET发送任何内容。
标签: javascript json react-native