( Note: I am a complete beginner in react native and have gone through a lot of reference searching for a solution and nothing helped.) I am using axios with https url for post request and this is my code.
try {
const response = await axios.post(
'https://aaa.bb.com/...................',
{
headers: {
// //Header Defination
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded', // tried application/json
'X-Requested-From': 'MOBILE',
'Authorization': 'Basic ' + loginCredential,
},
},
);
console.log('Success : ' + response);
} catch (error) {
// handle error
console.log(error);
}
I don't need the body part. I have used the same url with data on android native version and it worked fine. But on react-native I am getting "Error: Network Error" as message without any description. Tried using android:usesCleartextTraffic="true" in manifest.
Any help would be grateful. Thank you
I found the reason for the issue with the help of a web team. Actually this was not an issue with axios or react-native. This occur because of some url blocking issue from web side. Since that was the first time I was dealing with react-native and api calls I thought it was an issue from my side.
NB: I am not deleting or editing this question because there will be some beginners who come across same issue and think like the issue is from app side.
Thank you
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments