Skip to content
Snippets Groups Projects
Verified Commit 953f1b29 authored by Erick Hitter's avatar Erick Hitter
Browse files

Add additional forecast data

parent 132dcf9f
Branches
Tags
No related merge requests found
...@@ -98,18 +98,17 @@ app.post('/post', function(req, res){ ...@@ -98,18 +98,17 @@ app.post('/post', function(req, res){
var forecastData = JSON.parse( body ), var forecastData = JSON.parse( body ),
forecastText = forecastData.forecast.txt_forecast; forecastText = forecastData.forecast.txt_forecast;
var forecastBody = "##### Forecast as of " + forecastText.date + "\n"; var forecastBody = "##### Forecast as of " + forecastText.date + "\n";
forecastBody += "| Day | Forecast |\n"; forecastBody += "| Day | Forecast | High | Low |\n";
forecastBody += "|:--------------------|:------------------------------|\n"; forecastBody += "|:--------------------|:------------------------------|:----------|:----------|\n";
forecastText.forecastday.forEach( function( entry ) {
forecastBody += ' | ' + entry.title + ' | ' + entry.fcttext + " |\n";
} );
forecastBody += "| Monday, Feb. 15 | Cloudy with a chance of flurries | 3 °C | -12 °C |\n"; forecastText.forecastday.forEach( function( entry, index ) {
// forecastBody += '---'; 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 }; responseBody.attachments[1] = { "text": forecastBody };
res.send( responseBody ); res.send( responseBody );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment