From 132dcf9f2f4af3c446821f36c8d70c220a547c91 Mon Sep 17 00:00:00 2001
From: Erick Hitter <services@ethitter.com>
Date: Fri, 13 Jan 2017 23:12:40 -0800
Subject: [PATCH] Fill in forecast info

---
 index.js | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/index.js b/index.js
index 6051612..28f1261 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 += '---';
 
-- 
GitLab