所以我想将通知从一个设备推送到另一个设备,我为此使用了firebase云功能,当然还有node.js,当我搜索时我发现有一种新方法可以从firebase firestore检索id,但没有人解释它无论如何,这是我收到以下错误的node.js index.js:
TypeError: Cannot read property 'pharmacien_id' of undefined
at exports.sendCommandes.functions.firestore.document.onWrite.event (/user_code/index.js:8:35)
at Object.<anonymous> (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:112:27)
at next (native)
at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:28:71
at __awaiter (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:24:12)
at cloudFunction (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:82:36)
at /var/tmp/worker/worker.js:710:26
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
这是 index.js:
'use-strict'
const functions = require('firebase-functions');
const admin=require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendCommandes=functions.firestore.document("Pharmaciens/{pharmacien_id}
/Commandes/{commande_id}").onWrite(event =>{
const pharmacien_id=event.params.pharmacien_id;
const commande_id=event.params.commande_id;
console.log("pharmacien_id: "+pharmacien_id+" |commande_id: "+commande_id);
});