How do I save data to Firestore in Firebase Functions?
const functions = require('firebase-functions');
const admin = require('firebase-admin');
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
exports.saveContact = functions.https.onRequest((request, response) => {
admin.firestore().collection("contact").add({
name: request.name;
}).then(function(docRef) {
console.log("Document written with ID: ", docRef.id);
}).catch(function(error) {
console.error("Error adding document: ", error);
});
response.send("Hello from Firebase!");
});
With this code I'm getting this error
Error: could not handle the request