adrianhajdin / project_travel_advisor

Tutorial created in collaboration with Enyel Sequeira, taught by JavaScript Mastery.
MIT License
2.01k stars 444 forks source link

Open Weather Map API not returning a list of locations #8

Open xchiron opened 2 years ago

xchiron commented 2 years ago

When trying to add the below code segment to my Map component, I noticed that none of the weather icons were showing up.

{weatherData?.list?.map((data, i) => (
          <div key={i} lat={data.coord.lat} lng={data.coord.lon}>
            <img height={100} src={`http://openweathermap.org/img/w/${data.weather[0].icon}.png`}/>
          </div>
        ))}

Looking at the OpenWeatherMap documentation, I don't see a "list" property in the response. I'm wondering if the Open Weather Map API has changed so that it does not return a list of coordinates close to the given lat and lng anymore or am I misunderstanding how this line of code works in javascript? Still new to the language.

P.S. I'm really grateful for the content, this is absolutely enlightening!! Really appreciate the hard work you put into this!

djanlm commented 2 years ago

When trying to add the below code segment to my Map component, I noticed that none of the weather icons were showing up.

{weatherData?.list?.map((data, i) => (
          <div key={i} lat={data.coord.lat} lng={data.coord.lon}>
            <img height={100} src={`http://openweathermap.org/img/w/${data.weather[0].icon}.png`}/>
          </div>
        ))}

Looking at the OpenWeatherMap documentation, I don't see a "list" property in the response. I'm wondering if the Open Weather Map API has changed so that it does not return a list of coordinates close to the given lat and lng anymore or am I misunderstanding how this line of code works in javascript? Still new to the language.

P.S. I'm really grateful for the content, this is absolutely enlightening!! Really appreciate the hard work you put into this!

So, I was facing the same problem and I noticed that I was using the wrong endpoint, so make sure you are using the "SEARCH WEATHER DATA" endpoint and its URL is "https://community-open-weather-map.p.rapidapi.com/find"