0
votes

I am running my react native code on expo client. When I try to fetch from google.com, for instance, I get

"TypeError: Network request failed"

error.

I have internet on my device. This error message does not make sense in detail. How can I understand the real problem beneath.

  static test(provider, token, success, error) {
    console.log(1); // TODO: remove
    fetch("https://wwww.google.com", {
      method: "GET",
    })
      .then(response => {
        console.log(2); // TODO: remove
        if (response.ok) {
          success(response);
        } else {
          error(response);
        }
      }).catch(e => {
        console.log("RestService Error: " + e);
      });
  }

Update: Snack added.

https://snack.expo.io/@dijkstras/fetch-issue

1
I am trying to reach 'google.com' rather than a local area server. How could be the duplicate of the issue you mention, @Oleg ? - Eray Tuncer
Can you post snack example and test it? I want to eliminate the connection problem device with pc and network - Oleg
Added the snack - Eray Tuncer

1 Answers

1
votes

You added 4 'wwww' in url address. fixed snack: https://snack.expo.io/@djalik/fetch-issue