testmvc/server/weather.js
Martin Donnelly d332140d32 init
2017-10-27 21:26:27 +01:00

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;