5
votes

When I create a brand new project using react-native init (RN version 0.52-RC) and put a fetch in the render method to the public API, it throws a Network Request Failed. There is a very useless stack trace and I can't debug network requests in the chrome console. Here is the fetch I'm sending:

 fetch('https://test.online/login', {
            method: 'POST',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({
                email: this.emailId,
                password: this.password
            })
        }).then((data) => {
            return data.json();
        }).then((data) => {

        }).catch((err) => {
            alert(err); // TypeError:Network request faild.
        });
2

2 Answers

2
votes

if you are using nginx server then change

from ssl_ecdh_curve secp384r1 to ssl_ecdh_curve prime256v1

in this /etc/nginx/snippets/ssl-params.conf file

see detail to check here https://community.letsencrypt.org/t/warning-android-7-0-clients-not-browsers-can-only-use-curve-prime256v1/23212

0
votes

can you post your request code snippet? what simulator are you using Android or IOS? Generally, IOS/Android doesn't allow you to make http requests by default you have to enable them in your info.plist( for IOS )