From e524c3dc2efe0ab68715bd63484a738e4f873815 Mon Sep 17 00:00:00 2001 From: Zachary Smith Date: Sun, 13 Dec 2015 22:18:03 -0700 Subject: [PATCH] Write the data that comes back from the Google sheet to a file on the local server. This file is called catalog.json. It could be used as a fallback if the connection to Google was down. --- server.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 067410a..d08ad3d 100644 --- a/server.js +++ b/server.js @@ -29,12 +29,18 @@ app.use(function (req, res, next) { Tabletop.init( { key: public_spreadsheet_url, callback: showInfo, simpleSheet: true, - debug: true + debug: false } ) function showInfo(data, tabletop) { - console.log("Successfully processed!") - // console.log(data) + // Save the data to a flat file on the local server + fs.writeFile('./catalog.json', JSON.stringify(data), function(err) { + if (err) throw err; + else { + console.log('Successfully wrote google sheet data to catalog.json.') + } + }); + globalData = data next() }