【发布时间】:2020-12-29 18:23:15
【问题描述】:
我在 firebase 函数日志控制台中看到大量垃圾邮件日志消息,但我看不到我记录的那些,所以我希望看到的那些。
我的代码:
const createNotification = ((notification) => {
return admin.firestore().collection('notifications')
.add(notification)
.then(doc => console.log('notification added', doc)); //THIS IS THE LOG I EXPECT TO SEE
});
exports.userJoined = functions.auth.user()
.onCreate(user => {
return admin.firestore().collection('users')
.doc(user.uid).get().then(doc => {
const newUser = doc.data();
const notification = {
content: 'Joined the party',
user: `${newUser.firstName} ${newUser.lastName}`,
time: admin.firestore.FieldValue.serverTimestamp()
};
return createNotification(notification);
});
});
在promise中我也试过了:.then(() => console.log('notification added', notification));
通知是在数据库中创建的,但控制台中没有日志。
这次我很幸运,代码可以正常工作,但如果代码不能正常工作,我希望能够将内容注销。
在我的 reduxfirebase 配置中,我将 enableLogging 设置为 true,以防万一。
export const reduxFirebase = {
userProfile: 'users',
useFirestoreForProfile: true,
enableLogging: true
}
在 firebase 中调试服务器功能执行的任何提示也将受到赞赏。谢谢
预期日志:
【问题讨论】:
-
您可以分享您在函数控制台中所做 看到的日志吗?您的代码显然没有任何问题,因此查看您得到的输出会有所帮助。
-
问题中的更新图像。建议下拉的箭头不显示任何内容
标签: node.js firebase google-cloud-functions