0

i am working on a react-native application for about almost a year now, and a function i wrote earlier suddenly stopped working for now reason.. here's the code snippet:

   var array = [];
      fetch('https://reqres.in/api/products/3') //different URL, for testing only
              .then((response) => response.json())
              .then((json) => {  array = json; })
              .then(() => { console.log("get Remote data DONE" + array); 

this code worked great for some time, and now as i had to review my code it suddenly doesn't work anymore.. i get an "network request failed" error msg..

any ideas?

blendstylez
  • 341
  • 3
  • 16
  • 1
    On Jul 13, 2021 the site got a new certificate, maybe its CA is not trusted? This might help - https://stackoverflow.com/questions/33655832/fetch-in-react-native-wont-work-with-ssl-on-android?noredirect=1&lq=1 – olore Aug 31 '21 at 16:43
  • i've checked my api with this site: https://www.digicert.com/help/ and all certs seem to be fine..i've got no clue why this is happening now :/ – blendstylez Aug 31 '21 at 16:58
  • check if app is allowed to access internet – cuongtd Aug 31 '21 at 17:28
  • the issue is within the emulator, i installed a different one and my fetch command succeed's ;) i will try to re-install the emulator, and will report back here if that solves the problem – blendstylez Aug 31 '21 at 19:04

1 Answers1

-1

it turns out that the problem was not caused by code i wrote or by any other settings related to react-native. i tried a different emulated device, which i created for testing this issue, and the code completed without any issues at all while debugging on this very device. so i tried to simply wipe my previously used virtual device (https://github.com/google/android-emulator-m1-preview. and now everything is working just fine. problem solved! :)

blendstylez
  • 341
  • 3
  • 16
  • Please provide additional details in your answer. As it's currently written, it's hard to understand your solution. – Community Sep 01 '21 at 09:36