Home > Blockchain >  How can i know that my firebase cloud function is working or not?
How can i know that my firebase cloud function is working or not?

Time:01-27

I am created a firebase function which shown in below, but i don't how to debug it i am serving this with npm run serve

I am trying to creating, updating, deleting data in my real time database, if you see the reference is giving is development. but when i checking my rt DB it doesn't change anything. first i am editing my textEdit field after i see it doesn't update anything.

export const tri= functions.database.ref('/development').onWrite((change, context) => {
      //
      functions.logger.log("dddd", change, context)
      console.log("logggg", change.after.val())

      return change.after.ref.update({ textEdit: new Date() })
})                                                                                 

console.log("1")

CodePudding user response:

Don't use npm run serve use firebase serve to test and debug functions locally.

CodePudding user response:

You can use firebase emulators:start, emulators:start will start the emulator for your functions which allows you to test and debug your Functions locally,You can test your functions in this way before putting them into the production environment. You can interact with the functions in the same way you would when they were deployed once the emulators are running, which can help you quickly find and fix bugs and errors.you can check this document1 which is shared in above comment and also this document2 for more information

To run the Cloud Functions emulator, use the emulators:start command:

firebase emulators:start

The emulators:start command will start emulators for Cloud Functions, Cloud Firestore, Realtime Database, and Firebase Hosting based on the products you have initialized in your local project using firebase init. If you want to start a particular emulator, use the --only flag:

firebase emulators:start --only functions
  • Related