I am using Firebase Hosting/Firestore/Functions for a Vue app. Hosting + Firestore are working fine. Now I wanna add more functionality and wanted to add Functions. To test locally, I initiated a Firestore and can run all 3 emulators. Now, when I start the emulators and goto the hosting emulator, I can insert a record, which also shows up in production database, but the function is not triggered. It's onCreate. I deployed the function and it works fine. I can see the console.log().
Why are local/production writes not triggering the cloud function?
Here is the function:
export const sendWelcomeEmail = functions.firestore.document('/activeJobsTestDB/{jobId}').onCreate((data,context) => {
const inputRecord = data.data();
console.log('here' + inputRecord);
// const mailOptions = {
// from: '"Spammy Corp." <[email protected]>',
// to: inputRecord.email,
// };
});
i Starting emulators: ["functions","firestore","hosting"]
⚠ Your requested "node" version "8" doesn't match your global version "12"
✔ functions: Emulator started at http://localhost:5001
i firestore: Serving ALL traffic (including WebChannel) on http://localhost:8080
⚠ firestore: Support for WebChannel on a separate port (8081) is DEPRECATED and will go away soon. Please use port above instead.
i firestore: Emulator logging to firestore-debug.log
✔ firestore: Emulator started at http://localhost:8080
i firestore: For testing set FIRESTORE_EMULATOR_HOST=localhost:8080
i hosting: Serving hosting files from: dist
✔ hosting: Local server: http://localhost:5000
✔ hosting: Emulator started at http://localhost:5000
i functions: Watching "/Volumes/Work/playground/sforce-job/sforce-jobs/functions" for Cloud Functions...
> here
✔ functions[sendWelcomeEmail]: firestore function initialized.
✔ All emulators started, it is now safe to connect.
I goto localhost:5000 and can use my app as I want, but the function is not triggered. Any help will be highly appreciated.