当我使用fetch()进行http调用时,它使我“网络请求失败”。这是在Android和iOS物理设备上发生的。 (因为我正在使用expo,所以无法在android或iOS目录中进行任何修改)
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) => {
{/* All my business logic goes here..!! */}
})
.catch((error) => {
console.error(error);
});
};