React native axios post request network error on Android physical device

Pooja Rajendran C

( 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

Pooja Rajendran C

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.

edited at
0

Comments

0 comments
Login to comment

Related

React: Axios Network Error

React Native Post Request via Fetch throws Network Request Failed

Shake gesture not working on physical device with react native

React Native fetch() Network Request Failed for android?

Post request Axios : Network error

Network error with axios and react native

Network error in use of axios and fetch in react native

React-native - Axios GET request throws network error in Android emulator

React-Native Android 'Network Request failed'

Xcode 11.2.1 codesign error when building react native on a physical device

axios.post returns bad request of 400 React Native

Axios post request is not working in React Native

React Native Axios upload image return Network Error on Android

Network Error making post request using Axios

Axios network error even though the post request returns 200

React-Native physical device not connecting to server

React-native POST request in android over https return network error

React Native Fetch Request Network Error

Error Running React Native APP on Physical device

Network request failed when trying POST request in React-Native

Sending request headers / authorization axios.post in react-native

Issue Error Network with Axios on React-native

Error: Network Error using axios in React Native, issue in only in iOS and Android

Image not showing in react-native in a physical device

React native Axios post request works in iOS simulator but not physical phone

Network Error on formdata POST request React Native

axios Post returning error in react native

axios giving [AxiosError: Network Error] in react native

axios showing Network request failed error in react native