0

I got a problem with axios react native, I can't figure out what is the problem.

axios.catch method is send a error content's : Network Error

here's the content of /Android/app/src/main/AndroidManifest.xml :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.eruditio">

    <uses-permission android:name="android.permission.INTERNET" />
    
    <application
      android:networkSecurityConfig="@xml/network_security_config"
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:usesCleartextTraffic="true"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity
      android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
      android:theme="@style/BootTheme"
      android:launchMode="singleTask">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    </application>
</manifest>

the content of /Android/app/src/main/res/xml/network_security_config.xml (is SSL domain) :

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
</network-security-config>

thanks for interesting in my problem, I hope u can figure out what's the problem.

oboualla
  • 33
  • 9

1 Answers1

0

It might be related to known issue since axios 0.19.0, downgrading the axios to ^0.18.0 helped me in this case but here you can find more info and suggestions. Also potential duplicate question.

glava11
  • 11
  • 2
  • Thanks for helping, already I use "axios": "^0.21.1", but still doesn't work, but it works for local server and other servers, just on this server i think it's a security problem because i didn't found any log about the request that i made on /var/log/apache2/access.log or any errors on /var/log/apache2/error.log – oboualla Sep 01 '21 at 00:44
  • if you use the Flipper tool try also disabling it and check again – glava11 Sep 02 '21 at 09:43