26 lines
575 B
JavaScript
26 lines
575 B
JavaScript
|
|
const logger = require('log4js').getLogger('Weather');
|
|
const weather = require('openweather-apis');
|
|
|
|
logger.level = 'debug';
|
|
|
|
const openWeatherApiKey = process.env.openweatherAPI || '';
|
|
|
|
weather.setAPPID(openWeatherApiKey);
|
|
weather.setLang('en');
|
|
weather.setCity('Glasgow City');
|
|
|
|
function doGetOpenWeather() {
|
|
return new Promise((resolve, reject) => {
|
|
weather.getWeatherForecastForDays(5, function(err, wData) {
|
|
if (err)
|
|
return reject(err);
|
|
else
|
|
return resolve(wData);
|
|
});
|
|
});
|
|
}
|
|
|
|
module.exports.doGetOpenWeather = doGetOpenWeather;
|
|
|