Есть такой код запроса
backend() {
GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest;
let xhr = new XMLHttpRequest();
xhr.open("GET", `https://randomday.ru/newValue/?value=${this.state.text}`, true);
xhr.send();
xhr.onload = function() {
if (xhr.status !== 200) {
console.log(`Ошибка ${xhr.status}: ${xhr.statusText}`);
} else {
let json = JSON.parse(xhr.response);
this.setState({ text: json.msg });
}
}.bind(this);
xhr.onerror = function(e) {
console.log("Запрос " + e.target.status);
};
}
Запускается он при нажатии на кнопку
<Pressable onPress={() => {
this.backend()
}}
Все работает, когда я запускаю его в дебаг-режиме эмулятора или на устройстве android, но при запуске в обычном режиме выкидывается ошибка "0".
Мой AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myreact">
<uses-permission android:name="android.permission.INTERNET" />
<application
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>
</application>
</manifest>
В чем проблема?