[go: up one dir, main page]

Skip to content

Commit

Permalink
Hardcode the current date in the spreadsheet rows
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan committed Mar 11, 2018
1 parent 888ac93 commit 817bf16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cloud-function/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const functions = require('firebase-functions');
const admin = require('firebase-admin');
const cors = require('cors')({origin:'*', methods:['POST']});
const process = require('process');
const moment = require('moment');

admin.initializeApp(functions.config().firebase);
const db = admin.database();
Expand Down Expand Up @@ -89,14 +90,15 @@ exports.appendRecordToSpreadsheet = functions.https.onRequest((req, res) => {
let url = req.body.url;
let desc = req.body.desc;
let platform = req.body.platform;
let now = moment().format('M/D/YYYY H:m:s');
return cors(req, res, () => {
return appendPromise({
spreadsheetId: SHEET_ID,
range: 'A:D',
valueInputOption: 'USER_ENTERED',
insertDataOption: 'INSERT_ROWS',
resource: {
values: [['=NOW()', url, desc, platform]]
values: [[now, url, desc, platform]]
}
}).then(res.status(200).send('OK'));
});
Expand Down
1 change: 1 addition & 0 deletions cloud-function/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"firebase-functions": "^0.8.1",
"google-auth-library": "^1.3.1",
"googleapis": "^27.0.0",
"moment": "^2.21.0",
"process": "^0.11.10"
},
"devDependencies": {
Expand Down

0 comments on commit 817bf16

Please sign in to comment.