diff --git a/index.js b/index.js index 28f1261764a7c70e32b07c896e590084fd4ea959..53e8a35462e46639f2964fb5cdc212e4af9c756e 100644 --- a/index.js +++ b/index.js @@ -98,18 +98,17 @@ app.post('/post', function(req, res){ var forecastData = JSON.parse( body ), forecastText = forecastData.forecast.txt_forecast; - var forecastBody = "##### Forecast as of " + forecastText.date + "\n"; - forecastBody += "| Day | Forecast |\n"; - forecastBody += "|:--------------------|:------------------------------|\n"; - - forecastText.forecastday.forEach( function( entry ) { - forecastBody += ' | ' + entry.title + ' | ' + entry.fcttext + " |\n"; - } ); + forecastBody += "| Day | Forecast | High | Low |\n"; + forecastBody += "|:--------------------|:------------------------------|:----------|:----------|\n"; - forecastBody += "| Monday, Feb. 15 | Cloudy with a chance of flurries | 3 °C | -12 °C |\n"; - // forecastBody += '---'; + forecastText.forecastday.forEach( function( entry, index ) { + var forecastDetails = forecastData.forecast.simpleforecast.forecastday[ index ]; + if ( 'undefined' !== typeof forecastDetails ) { + forecastBody += ' | ' + entry.title + ' | ' + entry.fcttext + ' | ' + forecastDetails.high.fahrenheit + ' | ' + forecastDetails.low.fahrenheit + " |\n"; + } + } ); responseBody.attachments[1] = { "text": forecastBody }; res.send( responseBody );