kur*_*_89 7 json blob fetch react-native
嗨,所以我最近升级到0.24.1,我遇到了fetch的问题.我遇到的问题与https://github.com/facebook/react-native/issues/6025类似,但是body init正在返回一个Blob而不是像以前那样返回JSON.我做了更新,所以现在需要的头Accept & Content-Type
与application/json
他们没有像在上面的问题,但仍没有运气.
return fetch(`${auth0_api}/userinfo`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': `Bearer ${access_token}`
}
Run Code Online (Sandbox Code Playgroud)
当console.log
我收到回复时:
{
_bodyBlob: Blob
size: 1144
type: "application/json; charset=utf-8"
_bodyInit:Blob
size: 1144
type: "application/json; charset=utf-8"
headers: Headers
ok: true
status: 200
statusText: undefined
type: "default"
url: ""https://lite.au.auth0.com/userinfo""
}
Run Code Online (Sandbox Code Playgroud)
kur*_*_89 10
我可能应该在发布此问题之前阅读https://github.com/github/fetch ...
需要.json()
在响应中使用.
return fetch(`${auth0_api}/userinfo`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': `Bearer ${access_token}`
}
})
.then((response) => {
return response.json();
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7383 次 |
最近记录: |