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")
2
Answers
Don’t use
npm run serve
usefirebase serve
to test and debug functions locally.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 informationTo initialize Firebase Emulators locally