Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The callback function of weather.getSmartJSON is not working at all #40

Closed
bayoudhi opened this issue Dec 28, 2020 · 0 comments · Fixed by #41
Closed

The callback function of weather.getSmartJSON is not working at all #40

bayoudhi opened this issue Dec 28, 2020 · 0 comments · Fixed by #41

Comments

@bayoudhi
Copy link

bayoudhi commented Dec 28, 2020

Hello, I really like this module, especially how it's developed to be used directly in weather applications (based on the user's current city). However, I detected a problem when calling getSmartJSON

The callback function in method getSmartJSON is not working correctly --> neither the err object nor the smart object is returned, and I get this error when I run this code or even when I run the example.js code:

var weather = require('./index.js');

weather.setAPPID('2a1ad423e9fad1a3ceda81fda56b1366');
weather.setLang('it');
weather.setUnits('metric');
weather.setCity('roma');
// weather.setCoordinate(41.9152,12.5068)

weather.getSmartJSON(function(err,smart){

});

The error

/Users/abc/Projects/openweather-apis/index.js:192
      smartJSON.temp = jsonObj.main.temp;

TypeError: Cannot read property 'temp' of undefined
    at /Users/abc/Projects/openweather-apis/index.js:192:37
    at IncomingMessage.<anonymous> (/Users/abc/Projects/openweather-apis/index.js:265:18)
    at IncomingMessage.emit (node:events:339:22)
    at endReadableNT (node:internal/streams/readable:1289:12)
    at processTicksAndRejections (node:internal/process/task_queues:80:21)

This is a bug, I think that the function behind the callback is throwing an error rather than returning an error or a result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant