-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
22 lines (19 loc) · 815 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const functions = require("firebase-functions");
const admin = require('firebase-admin');
const cors = require('cors')({origin: "*"});
admin.initializeApp();
exports.createUser = functions.https.onRequest((request, response) =>
{
cors(request, response, () => {
//const currentTime = admin.firestore.Timestamp.now();
//request.body.timestamp = currentTime;
return admin.firestore().collection("users").add(request.body).then((snapshot) =>{
console.log("saved in database");
console.log(snapshot.id);
// console.log(snapshot.DocumentReference.toString());
// console.log("sending document reference id: ");
//console.log(DocumentReference[id]);
response.send(JSON.stringify(snapshot.id));
});
});
});