error每个then()应返回一个值或抛出promise / always-return

时间:2018-04-20 03:46:38

标签: javascript

部署我的代码时遇到了错误

  

16:49错误每个then()应返回一个值或抛出promise / always-return

这是我的index.js文件

'use-strict'
    const functions = require('firebase-functions');
    const admin = require('firebase-admin');
    admin.initializeApp(functions.config().firebase);
    exports.sendNotification=functions.firestore.document("BecomeProfessional/{user_id}/Notification/{notification_id}").onWrite( event => {

    const user_id = event.params.user_id;
    const notification_id = event.params.notification_id;

        return admin.firestore().collection("BecomeProfessional").doc(user_id).collection("Notification").doc(notification_id).get().then( queryResult => {

        const from_user_id = queryResult.data().from;

        const from_data = admin.firestore().collection("Users").doc(from_user_id).get();
        const to_data = admin.firestore().collection("BecomeProfessional").doc(user_id).get();
        return Promise.all([from_data, to_data]).then( result => {
            const from_name = result[0].data().name;
            const to_name = result[1].data().name; 
            console.log("FROM:" + from_name + "TO:" + to_name);
        });

      });

});

1 个答案:

答案 0 :(得分:1)

在您传递给[\d-]+的{​​{1}}回调函数的末尾添加return

then