我的firebase函数的错误没有记录到控制台

时间:2018-05-20 20:14:31

标签: javascript google-cloud-functions

我的firebase云功能拒绝记录从我的firestore传递给它的数据,并且在使用try和catch函数后它也拒绝显示错误。

import * as functions from 'firebase-functions';

const admin = require('firebase-admin')
admin.initializeApp(functions.config().firebase)

const ref = admin.firestore();

export const dailyCheck = functions.https.onRequest((request,
    response) => {
    console.log('load it again')
    const currentTime = new Date().getTime()
    const twoMonths = currentTime + 2592000000
    console.log(twoMonths + ' ----currentTime + 2months');
    console.log(currentTime + '---curentTime only');

    try {
        ref.collection('customers').where('finishDatemind', '<', 
        `${twoMonths}`)
        .get().then(data => {
            data.forEach(doc => {

                console.log(doc.data()+'here it is');

            })
        })
    }
    catch (e) { console.error(e) }

});

它在我的函数日志控制台上返回:

   1526845438060---curentTime only
   1529437438060 ----currentTime + 2months
   load it again

1 个答案:

答案 0 :(得分:3)

我刚刚找到答案。在查询我的Firebase Firestore时,我使用${twoMonths}代替twoMonths