Reactjs android物理设备上的网络请求失败
当我使用fetch()进行http调用时,它会抛出“网络请求失败”。这种情况发生在Android物理设备上。(因为我正在使用expo,所以无法在android或iOS目录中进行任何修改)Reactjs android物理设备上的网络请求失败,reactjs,react-native,Reactjs,React Native,当我使用fetch()进行http调用时,它会抛出“网络请求失败”。这种情况发生在Android物理设备上。(因为我正在使用expo,所以无法在android或iOS目录中进行任何修改) 您是否尝试过生产构建,而不是开发模式?如何做到这一点?是的。我已经试过了,但仍然遇到同样的问题。而且,在生产模式下,应用程序崩溃了。 passcodes = async () => { let data = { method: 'POST', credentials: '
您是否尝试过生产构建,而不是开发模式?如何做到这一点?是的。我已经试过了,但仍然遇到同样的问题。而且,在生产模式下,应用程序崩溃了。
passcodes = async () => {
let data = {
method: 'POST',
credentials: 'same-origin',
cache: 'no-cache',
mode: 'same-origin',
body: JSON.stringify({
"mobileNumber": this.state.mobileNumber,
"customerId": "my_customer_id",
"sessionId": "my_session_id"
}),
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
}
return await fetch(BaseUrl + 'my_endpoint_url', data)
.then((response) => response.json())
.then((responseJson) => {
this.setState({
passCodeText: passCodeData[0],
passCode: passCodeData[1],
visibleModal: 1,
backgroundImage: responseJson.generatePasscodeImage
});
})
.catch((error) => {
console.error(error);
});
};