I am building a react native app using expo and I am trying to connect to a http://localhost/api
running on my localhost. All I ma getting is network error.
The expo app is running on a real device. I did that using expo start --localhost --android
I have tried using the ip address provided by the ipconfig /all
instead of localhost but I am still getting Network Error
Here is my code
const fetchApi = async () => {
try {
const res = await axios.get("http://10.2.0.56:8000/");
console.log(res.data);
} catch (error) {
console.log(error.message);
}
};
Somebody please help