React Native Fetch request throwing "Network Request Failed" error in Laravel API

Viewed 1823

i trying to connect react native android application with Laravel Api. So i using a simple Api to testing whether the request were sent. When using POSTMAN it is working. But when i using emulator from android studio it throw the error of "Network Request Failed". What is the problems?

The API return json tested by POSTMAN:

{"result":"hello world"}

But in react native

enter image description here

This is my function

async onRegisterPressed() {
        let response= await fetch('http://127.0.0.1:8000/api/register',{
            method: 'POST',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                    name:this.state.name,
                    email:this.state.email,
                    password:this.state.password,
                    password_confirmation:this.state.password_confirmation,

            })
        });

        let res= await response.json();

            console.log(res);


}
1 Answers
Related