如何在HTTP触发器中使用Firebase Firestore

时间:2017-10-31 12:52:18

标签: firebase firebase-realtime-database google-cloud-firestore

如何在Firebase功能中将数据保存到Firestore?

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!");
});

使用此代码我收到此错误

  

错误:无法处理请求

0 个答案:

没有答案