I am very new to this realm of programming and I was running into some issues not with deploying my Firebase Function to my Firebase Project but testing the function itself and its execution.
The following is a test code I am using that should log the response when this testTrigger has been created with new data. But no luck, for some reason the deployment is successful but when I look at the logs they’re just notice logs that the deployment was successful, no execution logs. Anyone have any tips, I am quite lost.
Please let me know if you need more information!
Thanks ! 🙂
My code:
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp({
databaseURL: "https://databaseurl123.firebaseio.com/"
});
exports.checkDatabaseTrigger = functions.database.ref("/testTrigger")
.onCreate((snapshot, context) => {
console.log("data added testTrigger:", snapshot.val());
return null;
});
dependencies:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint . --fix",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "18"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^11.8.0",
"firebase-functions": "^4.3.1"
},
"devDependencies": {
"eslint": "^8.15.0",
"eslint-config-google": "^0.14.0",
"firebase-functions-test": "^3.1.0"
},
"private": true
}
Steps that I have followed:
- I deploy this very index.js script
- On my Firebase Functions I wait for the update of the function
- Then I go to my Realtime Database specifically this URL
- I then create the node and immediately type in a string of text like “Hello, World”
- Finally, I check the logs for any execution logs but to no avail
Hopefully, this is what you were looking for?
I have also tried to vary my index.js to call a 2nd gen cloud function but I get even more errors…