A. Parameters are reversed; should be (request, response)
B. Missing return statement
C. Incorrect function name
D. No error; code is correct
Solution
Step 1: Check HTTPS function parameters
HTTPS functions receive (request, response) parameters in that order.
Step 2: Identify parameter misuse
The code uses (resource, request) which reverses and misnames parameters.
Final Answer:
Parameters are reversed; should be (request, response) -> Option A
Quick Check:
HTTPS function params = (request, response) [OK]
Hint: HTTPS functions always use (request, response) parameters [OK]
Common Mistakes:
Swapping request and response parameters
Using resource parameter in HTTPS function
Ignoring parameter order importance
5. You want to write a Firebase function triggered by Firestore document changes. Which object should you use to access the changed document's data inside the function?
hard
A. resource.after.data()
B. request.body
C. context.params
D. resource.data()
Solution
Step 1: Understand Firestore trigger parameters
Firestore triggers receive a change object with before and after snapshots.
Step 2: Access the new document data
The updated document data is accessed via change.after.data(), which is the resource object.
Final Answer:
resource.after.data() -> Option A
Quick Check:
Firestore change after data = resource.after.data() [OK]
Hint: Use resource.after.data() for updated Firestore document data [OK]
Common Mistakes:
Using request.body which is for HTTP functions
Using context.params which holds path variables
Using resource.data() which is old snapshot, not updated
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.