简体   繁体   中英

errors to my firebase function does no log to console

My firebase cloud function refuses to log data that i passed to it from my firestore, and it also refuses to display errors after using try and catch functions.

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) }

});

it returns this on my functions log console:

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

I just found the answer. I used ${twoMonths} instead of twoMonths when querying my Firebase Firestore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM