Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Functions for Firebase Error occurred while parsing your function triggers

I had been trying to send emails to the users in Firebase using Cloud Functions for Firebase. I am referring to the repository of firebase function at https://github.com/firebase/functions-samples/tree/master/quickstarts/email-users

I install all the node packages for the firebase email function as required and explained on the repository. I edited TODO in the index.js file in functions as

    const functions = require('firebase-functions');
    const nodemailer = require('nodemailer');

// Configure the email transport using the default SMTP transport and a GMail account.
    // For other types of transports such as Sendgrid see https://nodemailer.com/transports/

// TODO: Configure the `gmail.email` and `gmail.password` Google Cloud environment variables.
    firebase functions:config:set gmail.email="[email protected]" gmail.password="gmailPassword"
    const gmailEmail = encodeURIComponent(functions.config().gmail.email);
    const gmailPassword = encodeURIComponent(functions.config().gmail.password);
    const mailTransport = nodemailer.createTransport(
        `smtps://${gmailEmail}:${gmailPassword}@smtp.gmail.com`);

When I try to deploy the function using the command

firebase deploy

It shows me the following error enter image description here

Error occurred while parsing your function triggers.

Could anyone please help me out in solving this.

like image 975
Vishal Vishwakarma Avatar asked Mar 26 '17 19:03

Vishal Vishwakarma


1 Answers

The functions:config is a command that you run with the Firebase CLI from the command prompt, not from your Functions code.

So in your command prompt/terminal:

firebase functions:config:set gmail.email="[email protected]" gmail.password="gmailPassword"
like image 131
Frank van Puffelen Avatar answered Oct 05 '22 23:10

Frank van Puffelen