diff --git a/index.js b/index.js index 60516125c47e43536645f5d1cda2be5be77ba08a..28f1261764a7c70e32b07c896e590084fd4ea959 100644 --- a/index.js +++ b/index.js @@ -95,11 +95,18 @@ app.post('/post', function(req, res){ } // Build forecast into a table - var forecastData = JSON.parse( body ); + 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"; + } ); - var forecastBody = "##### Forecast as of " + forecastData.forecast.txt_forecast.date + "\n"; - forecastBody += "| Day | Description | High | Low |\n"; - forecastBody += "|:--------------------|:---------------------------------|:-------|:-------|\n"; forecastBody += "| Monday, Feb. 15 | Cloudy with a chance of flurries | 3 °C | -12 °C |\n"; // forecastBody += '---';