0
0
Firebasecloud~10 mins

Why serverless functions extend Firebase - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize Firebase Functions in your project.

Firebase
const functions = require('[1]');
Drag options to blanks, or click blank then click option'
Afirebase-functions
Bfirebase-admin
Cfirebase-auth
Dfirebase-storage
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'firebase-admin' instead of 'firebase-functions' to write functions.
Confusing storage or auth packages with functions.
2fill in blank
medium

Complete the code to create an HTTP triggered serverless function.

Firebase
exports.helloWorld = functions.[1]((req, res) => { res.send('Hello from Firebase!'); });
Drag options to blanks, or click blank then click option'
Ahttps.onCall
Bhttps
Cdatabase
Dhttps.onRequest
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'https' without '.onRequest' which is incomplete.
Using 'https.onCall' which is for callable functions from clients.
3fill in blank
hard

Fix the error in the function trigger to respond to Firestore document creation.

Firebase
exports.newUser = functions.firestore.document('[1]').onCreate((snap, context) => { console.log('New user added'); });
Drag options to blanks, or click blank then click option'
Ausers/userId
Busers
Cusers/{userId}
Dusers/*
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'users/userId' which listens to a fixed document, not any document.
Using 'users' which is a collection, not a document path.
4fill in blank
hard

Fill both blanks to create a function that triggers on Firebase Authentication user creation and logs the user ID.

Firebase
exports.logNewUser = functions.auth.user().[1]((user) => { console.log('User ID:', user.[2]); });
Drag options to blanks, or click blank then click option'
AonCreate
Buid
ConDelete
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'onDelete' instead of 'onCreate' for user creation events.
Accessing 'email' instead of 'uid' when logging user ID.
5fill in blank
hard

Fill all three blanks to write a Firestore function that updates a user's profile when their document changes.

Firebase
exports.updateUserProfile = functions.firestore.document('[1]').[2]((change, context) => { const newData = change.[3].data(); console.log('Updated data:', newData); });
Drag options to blanks, or click blank then click option'
Ausers/{userId}
BonUpdate
Cafter
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'data' instead of 'after' to get new document data.
Using 'onCreate' instead of 'onUpdate' for document changes.