我正在使用 react native 0.48.3 并从获取请求中获取响应我没有看到任何编码问题它自己解决了编码问题,因为我的响应的内容类型是:application/json;charset=iso-8859-1 . 现在我将我的本机应用程序升级到 0.59.8 我不知道为什么 fetch 不再解决编码问题,尽管它是相同的代码。我刚刚升级了我的应用程序。你有什么主意吗 ?这是我的获取代码:
export const setDocumentListDataAsync = (k, action, server) => {
return () => {
fetch(defineUrlForDocumentList(action, server), {
credentials: 'include',
headers:{
contentType: "application/json; charset=utf-8",
}
})
.then(
(response) => {
var contentType = response.headers.get('content-type')
console.warn(contentType)
return response
}
).then((response) => {
return response.json()
}).catch((err) => {
console.log(err)
})
}
}