Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native fetch() Network Request Failed for android?

Tags:

react-native

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.
        });
like image 741
Durga prasad patra Avatar asked Oct 28 '22 21:10

Durga prasad patra


1 Answers

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

like image 90
Man Avatar answered Jan 02 '23 20:01

Man