TypeError: Network request failed
Unable to symbolicate stack trace: The stack is null
通過分析可以看出是網絡請求問題。在react native 中,嘗試fetch發送請求導致的問題。
關於fetch的代碼:
fetch('http://localhost:8083/user/getAllUser', {
method: 'POST',
headers: {
"Accept": "application/json",
"Content-Type": 'application/json',
"Connection": "close",
"type": "getUserData",
},
mode : "cors",
body : JSON.stringify({
page : 1,
type :0
})
}) .then((response) => response.json())
.then((responseJson) => {
console.log(responseJson);
return responseJson.movies;
})
.catch((error) => {
console.error(error);
});
在測試過程中提示錯誤。
1. Android 端接收的http請求必須是ip 即訪問地址必須是IP地址
2. 請求頭中必須包含一下內容