React-native fetch throws “Network request failed” error on Android Devices with backend in remote server

i used react native for mobile development and i used node js as a backend in a remote server(not localhost) with “188.226.146.190:3000/api/meetups”, but i got network error in android 5.1 physical devise and return undefined as output of api,what should i do? i used a simple get requset to my api. i test an example api “https://jsonplaceholder.typicode.com/users” and it works properly with this test api. i have an api file:

    export const fetchMeetups = () => 
        fetch('http://188.226.146.190:3000/api/meetups')
                .then(res => res.json()).catch((e) =>e);

and in the app.js:

static defaultProps = {
    fetchMeetups
}
state = {
    loading: false,
    meetups: []
}

async componentDidMount() {
    this.setState({
        loading: true
    });
    const data = await this.props.fetchMeetups();
    setTimeout( () => this.setState({loading: false, meetups: 
    data.meetups}),2000);
}

and in the android i got this error: Network request failed

Does this help?

this answer is about ios, i work around android. i install a new react native and i dont have android folder to change AndroidManifest.xml file that mention in one answers of this question

the ip has problem, the problem solved by using domain and ssl for the donain

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.