Recall & Review
beginner
What is an HTTP trigger function in Firebase?
An HTTP trigger function is a cloud function that runs when it receives an HTTP request. It lets you handle web requests like a web server.
Click to reveal answer
beginner
How do you define an HTTP trigger function in Firebase?
You define it using
functions.https.onRequest((req, res) => { ... }). This sets up a function that runs when an HTTP request is made.Click to reveal answer
beginner
What are the two main objects passed to an HTTP trigger function handler?
The two objects are
req (request) and res (response). req has info about the incoming request, and res is used to send back a response.Click to reveal answer
intermediate
Why would you use an HTTP trigger function instead of a regular Firebase function?
Because HTTP trigger functions let you create APIs or webhooks that respond to web requests directly, making your backend accessible over the internet.Click to reveal answer
beginner
How do you send a JSON response from an HTTP trigger function?
Use
res.json({ key: 'value' }) to send a JSON object back to the client.Click to reveal answer
Which method defines an HTTP trigger function in Firebase?
✗ Incorrect
Only functions.https.onRequest() sets up an HTTP trigger function.
What does the
res object do in an HTTP trigger function?✗ Incorrect
res is used to send back responses like text or JSON.How do you send a plain text response in an HTTP trigger function?
✗ Incorrect
res.send() sends plain text or HTML responses.Which of these is NOT a typical use case for HTTP trigger functions?
✗ Incorrect
Responding to database changes uses database triggers, not HTTP triggers.
What happens if you don't send a response in an HTTP trigger function?
✗ Incorrect
Without sending a response, the client waits until the function times out.
Explain how an HTTP trigger function works in Firebase and what objects it uses.
Think about how a web server handles requests and responses.
You got /5 concepts.
Describe a simple example of when you would use an HTTP trigger function in a Firebase project.
Imagine you want to let a website or app ask your backend for data.
You got /4 concepts.