const logger = require('log4js').getLogger('Weather'); const weather = require('openweather-apis'); logger.level = 'debug'; const openWeatherApiKey = process.env.openweatherAPI || '936a0ed9eb23b95cf08fc9f693c24264'; weather.setAPPID(openWeatherApiKey); weather.setLang('en'); // weather.setCity('Glasgow City'); function doGetOpenWeather(ll) { const [lat, long ] = ll.split(','); return new Promise((resolve, reject) => { weather.setCoordinate(lat, long); weather.getWeatherForecast( function(err, wData) { if (err) return reject(err); else return resolve(wData); }); }); } function doGetOpenWeatherForecast(ll) { const [lat, long ] = ll.split(','); return new Promise((resolve, reject) => { weather.setCoordinate(lat, long); weather.getWeatherForecastForDays(5, function(err, wData) { if (err) return reject(err); else return resolve(wData); }); }); } module.exports = { doGetOpenWeather, doGetOpenWeatherForecast };