Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29593

Network Request Failed in React Native Android

$
0
0

So, I have been trying to find the solution and solve this for the whole day since the afternoon and it's already 10:52 PM here.

Here is the code and it is from the official docs except that I changed the part of logging into the console:

useEffect(() => {getMoviesFromApi();}, []);function getMoviesFromApi() {return fetch('https://reactnative.dev/movies.json')  .then(response => response.json())  .then(json => {    console.log(json.movies);  })  .catch(error => {    console.error(error);  });}

The code was partiallyworking in the afternoon, although it may get errors in 4 or 5 refreshes. I have found solutions for requesting data from localhost. Do I need to change the IP address needed to connect to that API and if so, how do I do that? Since, I am pretty new to these, although I try to research many solutions from google, none of them suits me. enter image description here


Viewing all articles
Browse latest Browse all 29593

Trending Articles