question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Network Error when the app calls API.graphQL

See original GitHub issue

When the app is calling api.graphQL after login, I get a network error (More info shown below)

Here is the code i used to test it:

`const [system, setSystem] = useState({}); console.log(“testing”);

useEffect(() => { //https://dev.to/rmuhlfeldner/how-to-use-an-aws-amplify-graphql-api-with-a-react-typescript-frontend-2g79 checkAuthState();

async function getData() {
  console.log("get Data");

  try {
    const QueryData = await API.graphql({query:getQuerySystem,variables:{id:"Lambert"}});
    console.log("test 2");
    setSystem(QueryData);
    console.log(system.Temp);
  } catch (error) {
    console.error("Error fetching todos", error);
   
  }
}
getData();

}, []); async function checkAuthState() { try { await Auth.currentAuthenticatedUser(); console.log(‘✅ User is signed in’); } catch (err) { console.log(‘❌ User is not signed in’); console.error(err); } }`

checkAuthState() function returns : ✅ User is signed in

Screenshot of the error message on the app image

If any more info is needed feel free to ask below. Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
amhinsoncommented, Oct 23, 2020

Are you running the API locally with a mock by chance? If so, is the address http instead of https? The Android emulator or physical devices connected via USB can sometimes have issues connecting to a local url.

0reactions
github-actions[bot]commented, Nov 2, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling operation errors - Apollo GraphQL Docs
When a network error occurs, Apollo Client adds it to the error.networkError field returned by your useQuery call (or whichever operation hook you...
Read more >
Network Error when initiating a query to my graphql API
Here's my client request : const client = new ApolloClient({ uri: 'https://my-app.herokuapp.com/', headers: { authorization: "Bearer API_KEY ...
Read more >
Resolve unauth errors for GraphQL requests in AWS AppSync
For a 401 Unauthorized response, check the network request that sends the GraphQL payload to confirm that: The Authorization or x-api-key header ...
Read more >
Top GraphQL Errors and How to fix them
All the errors above come under the category of GraphQL errors with a response status code of 200 . When there is a...
Read more >
GraphQL Content API - Contentful
The GraphQL Content API responses via GitHub contains errors that occur during the different phases of a request (authentication, validation, schema generation ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found