1

I have a WAMP server on my localhost, and I'm trying to run the php file inside of it, through my react native app in order to store user information. I know I needed to use my localhost's IPv4, and the port number, then the file location, but I still keep on getting: 'Possible Unhandled Promise Rejection (id: 0): TypeError: Network Request failed', while running my app on an ios device on the expo app.

I've tried making it an https instead of http, but i still keep on getting the same error, I've copy pasted the link into google chrome and it runs the php file, but when i do it on another device on the same network, it takes a very long time to connect but then it times out right away, and yes, my server is online.

fetch('http://[My server's IPv4 address]:80/Fetcher/Users.php', {
            method: 'POST',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                username: this.state.username,
                password: this.state.password,
            })
        }).then((response) => {response.json()}).then(fullResponse => {
            console.warn(fullResponse);
            console.warn('out');
        }).catch(err => console.error(err));

I expected it to take in the username and password and store them on the table I created on my WAMP server's table under the schema I've created.

What happens instead is I get a Network request failed error on my app

yoyo
  • 523
  • 2
  • 6
  • 14

1 Answers1

0

It looks like you are facing the same issue as in this post.

By default Android & iOS are blocking cleartext HTTP resource loading. You'll need to enable it both on iOS and Android as described in the post.

Using https in this case won't work because you do not have a valid server certificate.

Also check the same post for possible other sources of this issue.

tvanlaerhoven
  • 709
  • 5
  • 15
  • it appears that i have mutliple info.plist files, do you know which one i should edit? Also my project isn't ejected, so it's for both ios and android – yoyo Aug 21 '19 at 23:55