I've encountered an issue while trying to fetch data from a collection called "users" in Firebase onUpdate of a document named "bulkMsgs". Each time I attempt this, I receive an error message saying "Error getting user". Both methods work perfectly fine on their own, but when combined, the error occurs.
What could possibly be causing this error?
var functions = require("firebase-functions");
let admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.bulkMsg = functions.firestore
.document('/bulkMsgs/{bulkMsgsId}').onUpdate((snap, context) => {
const newValue = snap.after.data();
const regDate = newValue.regDate;
admin.firestore().collection('users').get().then(onUser => {
onUser.forEach(oneUser => {
if (oneUser.data().notification === "true") {
console.log(oneUser.id);
}
});
return true;
}).catch(err => {
console.log('Error getting user', err);
});
return true;
});
View Image showing the error in the Cloud Function log.