【发布时间】:2020-06-03 14:22:33
【问题描述】:
我正在调用 Functions 函数来获取用户信息,但它返回 null。 请告诉我解决方案。
工作区/函数/src/index.ts
exports.getUser = functions.https.onCall((data, context) => {
admin.database().ref(`user/${data.userId}`)
.on('value', (snapshot) => {
if (snapshot) return snapshot.val();
});
});
workspace/src/app/sample.component.ts
firebase.functions().httpsCallable('getUser')({
userId: profile.userId
}).then(data => {
console.log(data);
}).catch(error => {
alert(error);
});
【问题讨论】:
标签: javascript angular firebase firebase-realtime-database google-cloud-functions