Complete the code to initialize Firebase Functions in your project.
const functions = require('[1]');
The firebase-functions package is used to write serverless functions that extend Firebase capabilities.
Complete the code to create an HTTP triggered serverless function.
exports.helloWorld = functions.[1]((req, res) => { res.send('Hello from Firebase!'); });
The https.onRequest method creates an HTTP function that responds to web requests.
Fix the error in the function trigger to respond to Firestore document creation.
exports.newUser = functions.firestore.document('[1]').onCreate((snap, context) => { console.log('New user added'); });
The path users/{userId} uses a wildcard to trigger on any new user document creation.
Fill both blanks to create a function that triggers on Firebase Authentication user creation and logs the user ID.
exports.logNewUser = functions.auth.user().[1]((user) => { console.log('User ID:', user.[2]); });
The onCreate trigger runs when a user is created, and uid accesses the user's unique ID.
Fill all three blanks to write a Firestore function that updates a user's profile when their document changes.
exports.updateUserProfile = functions.firestore.document('[1]').[2]((change, context) => { const newData = change.[3].data(); console.log('Updated data:', newData); });
The function triggers on updates to any user document (users/{userId}) using onUpdate. The new document data is accessed with after.data().