ReferenceError: firebase not defined in cloud functions

I am new to firebase, but when I deploy my functions and execute the method onWrite(), this is the error I get:

ReferenceError: firebase not defined at export.sendJobNotification.functions.database.ref.onWrite.event (/user_code/index.js:11haps) on / user _code / node_modules / firebase-functions / lib / cloud-functions.js: 35:20 on process._tickDomainCallback (internal / process / next_tick.js: 135: 7)


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

const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

exports.sendPaymentNotification = functions.database.ref('payments/{paymentID}').onWrite(event => {
    if (event.data.previous.exists()) {
        return;
      }

      firebase.database().ref('payments').child(event.params.paymentID).once('value').then(function(snap){
            var jobData = snap.val();
            console.log(jobData)
      });
});
+4
source share

Source: https://habr.com/ru/post/1684729/


All Articles