React-native: Network Request Failed

Created on 25 Sep 2017  路  12Comments  路  Source: facebook/react-native

screenshot_2017-09-22-13-18-50-54

var SERVER_SIGNUP_URL = 'https://192.168.0.80/Registration/Registration.php';
fetch(SERVER_SIGNUP_URL + '?username=' + this.state.username + '&password=' + this.state.password)
.then((response) => response.json())
.then((responseData) => {
var id = responseData.id;
if (id === -1) {
this.hideProgressBar();
showMessage("Something is bad", "This username is already taken");
}
else {
this.props.navigator.push({
name: 'contacts',
password: this.state.password,
id: id,
username: this.state.username
});
}
})
.done();

Ran Commands Locked

Most helpful comment

if someone try to use emulator fetching "http://localhost/" or http://127.0.0.1/,
change them to '10.0.2.2'

All 12 comments

I have this problem too on android

if someone try to use emulator fetching "http://localhost/" or http://127.0.0.1/,
change them to '10.0.2.2'

@facebook-github-bot no-template

Hey, thanks for reporting this issue! It looks like your description is missing some necessary information, or the list of reproduction steps is not complete. Can you please add all the details specified in the Issue Template? This is necessary for people to be able to understand and reproduce the issue being reported. I am going to close this, but feel free to open a new issue with the additional information provided. Thanks! See "What to Expect from Maintainers" to learn more.

@AAGSICON @1048034876 - hey guys, have you reach a fix for it please? I'm stuck. Thanks a lot!

im stuck this too.

you can try your ip instead of localhost

Dont get your ip from a website like findmyip.com go to the cmd and ipconfig

I had the same error using http://localhost:8000 as my development server.

I think on react native 0.52.x it worked fine, but after upgrading to 0.54.x it caused the network request failed error.

As mentioned in https://github.com/facebook/react-native/issues/16081#issuecomment-332762429 and https://github.com/facebook/react-native/issues/16081#issuecomment-352639342, replacing localhost with my actual IP (not 127.0.0.1) didn't cause the error anymore.

how to change the default IP address as development server?

Was this page helpful?
0 / 5 - 0 ratings