diff --git a/src/playground/blocks/block_expansion_weather.js b/src/playground/blocks/block_expansion_weather.js index aa92c36d9d..43b8555093 100644 --- a/src/playground/blocks/block_expansion_weather.js +++ b/src/playground/blocks/block_expansion_weather.js @@ -3,16 +3,17 @@ const { getStateOptions, getCityOptions, locationData } = require('../../util/lo const { callApi } = require('../../util/common'); function resolveData(weatherData, type, dateStr) { + const defaultData = Entry.EXPANSION_BLOCK.weather.defaultData; try { + let key = Entry.EXPANSION_BLOCK.weather.getDate(dateStr); if (type === 'now') { - return weatherData[Object.keys(weatherData)[0]]; + key = Object.keys(weatherData)[0]; } else if (type === 'hour') { - return weatherData[dateStr]; - } else { - return weatherData[Entry.EXPANSION_BLOCK.weather.getDate(dateStr)]; + key = dateStr; } + return weatherData[key] || defaultData; } catch (e) { - return Entry.EXPANSION_BLOCK.weather.defaultData; + return defaultData; } }