【发布时间】:2021-01-03 16:25:22
【问题描述】:
我已经编写并部署了一个 Firebase 函数。该函数应该从用户那里获取一个值,即 orgKey,如果它等于 firestore 中的 orgKey,则该函数返回附加到该 orgKey 的 userType。我知道该函数接收来自客户端的输入,但它总是返回 null,无论我是否发送应该工作的 orgKey。 谁能告诉我怎么了?
index.js
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.authOrgKey = functions.https.onCall((data, context) => {
db = admin.firestore();
functions.logger.log('data passed to function: ', data);
db.collection("Orgkeys")
.get()
.then(snapshot => {
snapshot.forEach(doc => {
if (doc.orgKey == data) {return doc.userType}
});
return false;
});
});
【问题讨论】:
标签: javascript node.js firebase google-cloud-firestore google-cloud-functions