CICCIOSGAMINO / openweather-apis

Simple APIs for OpenWeatherMap.org basic services
GNU General Public License v3.0
44 stars 27 forks source link

getSmartJSON retrieves null #33

Closed aeri closed 4 years ago

aeri commented 4 years ago

When i am using the function getSmartJSON with the latest version of package and a valid API key it returns null.

The other functions like getTemperature or getAllWeather works well.

Why can this happen?

Using nodejs v12.16.1

faustyn-p commented 4 years ago

@aeri

It turns out that the getSmartJSON function returns error and response (in this order).

return callback(err,smartJSON);

Therefore, if you want to get a result, you should do it this way (for example):

weather.getSmartJSON((err, response) => {
    console.log(response);
});

@CICCIOSGAMINO My suggestion is to include this in the readme file, currently it is actually a bit misleading.

aeri commented 4 years ago

Thank you @faustyn-p the documentation is wrong and I directly took that example.

@CICCIOSGAMINO please fix that