troubleshooting Question

Failed to load resource GraphQL/React

Avatar of Richard Comito
Richard ComitoFlag for United States of America asked on
JavaScriptAWSReact
7 Comments2 Solutions65 ViewsLast Modified:
I am setting up a simple weather app using React/AWS Amplify/AWS Appsync/GraphQL.

I am getting the following errors when I open the console.

Failed to load resource: https://(appsync ID).appsync-api.us-east-1.amazonaws.com/graphql
net::ERR_NAME_NOT_RESOLVED

and

Uncaught (in promise) 
  1. Object
    1. data: {}
    2. errors: [GraphQLError]
    3. __proto__: Object

I am a noob to React and have not used Javascript in 15 years.  So end-user error I am suspecting.

Here are my questions and code.

1) How do I go about troubleshooting these types of issues in the future?
2) How do I hand off the variable to the query to be used by appysync?
3) How do I resolve the Error just in case I am way off on my assumption?


\\Weather Componant

import React, { Component } from 'react'
import { weatherByCity } from '../graphql/queries'
import { API, graphqlOperation } from 'aws-amplify'




class DisplayWeather extends Component {

    componentDidMount = async () => {
        this.getWeather()
    }

    getWeather = async () => {

            const result = await API.graphql(graphqlOperation(weatherByCity))
            console.log('weatherByCity', JSON.stringify(result))

    }

    render() {
        return (
            <div>
                data
            </div>
        )
    }
}

export default DisplayWeather




//Query.js
/* eslint-disable */
// this is an auto generated file. This will be overwritten

export const weatherByCity = /* GraphQL */ `
  query WeatherByCity($city: String!) {
    weatherByCity(city: $city) {
      timestamp
      location
      condition
      description
      temperature
      pressure
      humidity
      wind_speed
      wind_direction
      cloud_cover
      rain_volume
      snow_volume
    }
  }
`;




Any advice is welcome.  Thank you in advance.

Rich

ASKER CERTIFIED SOLUTION
leakim971
Multitechnician
Join our community to see this answer!
Unlock 2 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros