如何将Cloud Function的结果提供给客户端?

时间:2019-02-08 07:04:09

标签: firebase dart flutter google-cloud-functions

如何将Cloud Function的结果提供给客户端?我有下面的代码,我返回文档ID只是为了进行测试。如何在客户端上获得结果?

exports.addEvent = functions.https.onCall(async (data, context) => {
    const events = db.collection('events');
    try {
        await events.add({
            city: data["city"],
            dateFinish: data["dateFinish"],
            dateStart: data["dateStart"],
            eventName: data["eventName"],
            participants: data["participants"],
            place: data["place"],
            placeName: data["placeName"],
            public:data["public"],
            street: data["street"],
            userUid: data["userUid"],
        }).then(doc=>{
            doc.update(doc,{
                eventId: doc.id
            })
            return doc.id;
        })
    } catch (error) {
        console.log(error);
    }
});

0 个答案:

没有答案