I am using expo client on my android device and have setup up a django server at localhost:8000
and i'm trying to access and endpoint using fetch in react native. I have looked at How can I access my localhost from my Android device?How do you connect localhost in the Android emulator? and How to connect to my http://localhost web server from Android Emulator in Eclipse but that did not work.
I also tried using my machine's ip address instead of localhost, but no results. Here is a sample code
componentDidMount(){
return fetch('http://my-ip-address:8000/restapi/')
.then((response) => {
console.log("success")
response = response.json()
}).catch(error => {
console.error(error)
})
}
What am I doing wrong here?