I'm trying to console.log a document from Firestore in a Firebase Cloud Function. Can someone help me with the code ?
export const getUser = functions.https.onRequest((req, res) => {
const uid = req.query.uid
corsHandler(req, res, () => {
onUpdate(res, uid)
})
})
function onUpdate(res, uid) {
functions.database.ref(`/profiles/{profileId}`).onUpdate((change, context) => {
const profileId = uid
console.log('BEFORE: ', change.before.val())
res.send('OK')
})
}