【发布时间】:2019-05-16 18:42:43
【问题描述】:
我试图了解承诺是如何从 firebase 函数响应客户端的方式工作的,我将在这里举一个非常简单的例子:
这是保存一些数据的离子方法,然后在firebase中触发一个函数:
helloworld() {
this.db.list(`/helloWorld/${this.userId}`).push({status: false})
.then(res => console.log(res))
}
Firebase 函数触发
exports.helloWorld = database
.ref('helloworld/{id}')
.onWrite((change, context) => {
const data = change.after.val();
const id = context.params.id;
return admin
.database()
.ref(`/helloWorld/${id}`)
.set({ status: true }).then((res) => res);
});
【问题讨论】:
标签: firebase ionic-framework firebase-realtime-database ionic3 google-cloud-functions