noazark / weather

real weather for Javascript
MIT License
228 stars 108 forks source link

Weather Info Not Correct #30

Closed ruidiasbraga closed 4 years ago

ruidiasbraga commented 5 years ago

Hi,

I am requesting Weather for "Braga, PT", the information on the response, coordinates, id etc all correct, except the weather information like temperature and type of weather

I get like 15ºc light rains when in the site openweathermap.org I get 8ºC clear sky. What is the problem?

delsuza commented 5 years ago

Hi, it's because the getCurrent function fetch the wrong endpoint : var url = "http://api.openweathermap.org/data/2.5/forecast?q=" + encodeURIComponent(city) + "&cnt=1";

the good endpoint is : var url = "http://api.openweathermap.org/data/2.5/weather?q=" + encodeURIComponent(city) + "&cnt=1";

Some functions must be edited :

Weather.Current.prototype.temperature = function () {
  return this.data.main.temp;
};

Weather.Current.prototype.conditions = function () {
  return this.data.weather[0].description;
};