Dude, how have you got 4 elements in you weatherDiv array??? There’s only supposed to be one and it should be called weatherDiv not plural 's. Did you add more?
I have the same issue. I then doublechecked the stuff, and it does not seem to have any issue? I checked the hints and everything seems to be in order. Can anyone please tell me what’s going on here?
You use it correctly in your getForecast() function, but in your getVenues() function you have this:
Once you fix that, you’ll see the next error message about the incorrect variables being used in getForecast() but those error messages will be a lot more obvious.
EDIT2: Ok. Apologies for this, but I fixed it. Instead of "return"ing the response of weather data, I was “logging” it in “console”, and hence I could not see the result. I went back to each step of the way, and then realised it was console.log and not return json.response. Once I fixed it, it was done!> Thanks for helping point out the first error!
Thanks a lot for this help. These tiny mistakes, lol. Not sure how I missed it in console.
I went back and I did change the values for it (had to open the hint and copy those in because I didn’t read the step properly. But now I am stuck on this error, but this is all using the code in hints that was provided by the exercise, so I’m not sure why weather doesn’t render. Perhaps if I could get a better explanation of this error? Is this related to something with the “helperFunction” file? Because that’s the only place where I see ‘main’ being defined (in the section of converting temperatures). Updated code below:
You’re welcome. Sometimes the errors even more cryptic because it pops up in code you didn’t write since you’re passing data around.
It’s related to the helper function only in that it’s receiving data it doesn’t like. That data is coming from a series of function calls though. I’ll walk you through my thought process for debugging this to see if it helps you in the future. In this, we know that it’s also logging “Request failed!” and/or it isn’t showing the JSON for the weather, but you are seeing JSON from the other. For that reason, we’d want to dive deeper into the getForecast() function:
We know we aren’t seeing JSON from your console.log() so it never enters that block of code. The condition stopping it is if(response.ok). The response value is being set in the previous line:
response = await(urlToFetch);
We could add some logging after this line to check what response is getting assigned, but in this case, we know that await(urlToFetch) isn’t valid because fetch is missing.
If you fix that, you’ll see JSON in your console for weather. You’ll get a different error, but that’s still progress!
Hint about the next error
It’s going to complain about Cannot read property 'forecastDay' of undefined
If you examine the JSON by clicking the chevron (the little triangle thingy) next to the weather JSON, you’ll see that the forecast.forecastDay you added to jsonResponse to get the data isn’t valid. You can remove that. You only need to return the JSON
The ‘fetch’ was the first thing I went back to fix. Thanks for catching that. And yup. Removed the forecast.forecast days and works fine without. Thanks a lot for bearing with me here. This logging sure did help learn a bit more about the errors, esp. how and where the ‘main’ error was coming from, and your explanation is quite similar to how I explored this and other problems, so that’s a plus! Thank you!
Thank you for your help. I was rushing a bit and missed few important details in the process. I am baffled how I managed to miss to return venues in const getVenues.