I wrote test cloud function that will trigger at adding new like to post in my Cloud Firestore database. In body of the function then I want to get user tokens in order to send notification to him(have not implemented it yet). When I am trying to deploy this cloud function to firebase, I get this error: "error Parsing error: Unexpected token tokensRef". What can be wrong?
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();
const db = admin.firestore();
exports.showNotification = functions.firestore
.document("users/{userId}/posts/{postId}/likes/{joinedId}")
.onCreate((snap, context) => {
const userId = context.params.userId;
const tokensRef = db.collection("users").doc(userId).collection("tokens");
const snapshot = await tokensRef.get();
snapshot.forEach(doc => {
console.log(doc.id, '=>', doc.data())
})
});
ESlint config:
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"google",
],
rules: {
quotes: ["error", "double"],
},
};