burning in firebase using firebase cloud function

0

Good afternoon community Developers .... difficulty recording using firebase ...

The firebase cloud functions console gives this error message:

decode64(userTo) ********@gmail.com
decode64(userFrom) YWRyaWVsQHVuaXBsYWNsYWdlcy5lZHUuYnI=
Uncaught exception
ReferenceError: ut is not defined

My code looks like this:

let ut = decode64(userTo)
let uf = encode64(userFrom)
console.log('decode64(userTo)', ut)
console.log('encode64(userFrom)', uf)


db.collection('users').doc(ut).collection('contacts').doc(uf).set({
lastMessage: messageDoc.content,
lastMessageTime: new Date()
}, {
    merge: true 
}).then(() => {
    console.log('[END]');
    resolve(true);
    return true;
}).catch(e => {
    throw new Error("User last message not saved.");
});

Thank you in advance ...

    
asked by anonymous 05.11.2018 / 19:01

1 answer

0

it started working when I added the following lines >

            let ut = decode64(userTo)
            let uf = encode64(userFrom)
            console.log('decode64(userTo)', ut)
            console.log('encode64(userFrom)', uf)

            console.log('db.collection -> ', db.collection('users')) //essas 3 linhas
            console.log('db.collection.ut -> ', db.collection('users').doc(ut))
            console.log("db.collection('users').doc(ut).collection('contacts')",db.collection('users').doc(ut).collection('contacts'))

            db.collection('users').doc(ut).collection('contacts').doc(uf).set({
                lastMessage: messageDoc.content,
                lastMessageTime: new Date()
            }, {

It just started working !!!

    
05.11.2018 / 19:31