Skip to content

Commit

Permalink
Write the data that comes back from the Google sheet to a file on the…
Browse files Browse the repository at this point in the history
… local server. This file is called catalog.json. It could be used as a fallback if the connection to Google was down.
  • Loading branch information
Zachary Smith committed Dec 14, 2015
1 parent 8290ac2 commit e524c3d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit e524c3d

Please sign in to comment.