diff --git a/apps/owmweather/lib.js b/apps/owmweather/lib.js index b4893d484..2f6af5f7b 100644 --- a/apps/owmweather/lib.js +++ b/apps/owmweather/lib.js @@ -27,9 +27,8 @@ function parseWeather(response) { json.weather = weather; require("Storage").writeJSON('weather.json', json); if (require("Storage").read("weather")!==undefined) require("weather").emit("update", json.weather); - return undefined; } else { - return /*LANG*/"Not OWM data"; + throw /*LANG*/"Not OWM data"; } } @@ -43,12 +42,8 @@ exports.pull = function(completionCallback, errorCallback) { let uri = "https://api.openweathermap.org/data/2.5/weather?lat=" + location.lat.toFixed(2) + "&lon=" + location.lon.toFixed(2) + "&exclude=hourly,daily&appid=" + settings.apikey; if (Bangle.http){ Bangle.http(uri, {timeout:10000}).then(event => { - let result = parseWeather(event.resp); - if (result === undefined) { - if (completionCallback) completionCallback(); - } else { - if (errorCallback) errorCallback(result); - } + parseWeather(event.resp); + if (completionCallback) completionCallback(); }).catch((e)=>{ if (errorCallback) errorCallback(e); });