Okay I give. the weather app is making me ask for help

So I know it’s feeding the LAT and LONG to the cLat cLong variables. Because remove this code and it’s will pump out the lat and the long results in the app. The console log doesn’t show any data. I’m on a month and 7 days with this challenge. Granted not daily just hitting a wall.

Blockquote
var url = " https://fcc-weather-api.glitch.me/api/current?lat=“+cLat+”&lon=" +cLong;
async function getData() {
let response = await fetch(url)
let data = await response.json()
console.log(data)

Blockquote

So just double checked my result of the URL code the result of that variable is my Lat and Long for my current location. So maybe I’m using Fetch wrong. So next step see if I can get the JSON to output to the console.

There this finally worked to get me the JSON data into the console log now time to start access and assigning values to my variables that are in place.

    var url = " https://fcc-weather-api.glitch.me/api/current?lat="+cLat+"&lon=" +cLong;
    
 fetch(url)
  .then(
    function(response) {
      if (response.status !== 200) {
        console.log('Looks like there was a problem. Status Code: ' +
          response.status);
        return;
      }

      // Examine the text in the response
      response.json().then(function(data) {
        console.log(data);
      });
    }
  )
  .catch(function(err) {
    console.log('Fetch Error :-S', err);
  });

If promises work then that is a valid solution.

Not sure why you had issues with await / async. I hard coded a lat and a long into your code and it worked for me. Could there have been an issue with the url formation? Maybe console.log(url) might shed some light on that.

This below worked for me in CodePen returning an object that I could view in console

var url = "https://fcc-weather-api.glitch.me/api/current?lat=38&lon=99";
async function getData() {
  let response = await fetch(url);
  let data = await response.json();
  console.log(data);
  console.log("done");
}
getData();

Oh well. I’m glad you found a solution - 5 weeks is a long time.

1 Like

Yup granted I did wander off and work on other projects. This week I go stubborn and refused to walk away and do other things. Its also helped that I settled a job issue in those ensuing weeks and didn’t have that distraction this week.