简体   繁体   中英

One Specific API call fails only on Android ( react-native )

I have a react-native app that logs in and grabs user information based on the following code:

TestCall(){
    console.log(`${myLocation}/login`);
        return fetch(`${myLocation}/login`, {

            method:'POST',
            headers: {Accept: 'application/json',
                        'Content-Type': 'application/json',
        },
        credentials: "include",
        body: JSON.stringify({
            email:this.state.email,
            password:this.state.password,
        })
        })
  .then(response => response.json())
  .then(json => console.log(json))
}

I have different options for myLocation because I'm using this to grab account info from multiple sites that all allow login based on email and password. All start with https. This works perfectly for IOS no matter what I'm using for myLocation. This works perfectly on Android for all except for one option for myLocation.

For this specific combination of this specific myLocation and Android I get 'Network Request Failed' no matter which user account I try. This includes user account/myLocation combos that work on IOS. It's not giving me a 400, or 404, or 500 or anything like that because it's not even getting that far. When I use catch to see what's happening it just goes straight to the catch and always gives me the 'Network Request Failed' as the error that's being logged.

Also, I am using Android emulator and IOS simulator on the same computer so IP gateway and IP address are the same for both. Only user agent is different (okhttp for android and CFNetwork Darwin for IOS). I'm stumped. Does anyone know why this would be happening? Thanks!

This problem went away after the certificate was changed for the site that I was having a problem with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM