0
0
Firebasecloud~5 mins

HTTP trigger functions in Firebase - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Afunctions.database.onWrite()
Bfunctions.auth.user().onCreate()
Cfunctions.https.onRequest()
Dfunctions.storage.onFinalize()
What does the res object do in an HTTP trigger function?
AContains info about the incoming request
BSends a response back to the client
CTriggers the function execution
DStores data in the database
How do you send a plain text response in an HTTP trigger function?
Areq.send('text')
Bres.json('text')
Creq.json('text')
Dres.send('text')
Which of these is NOT a typical use case for HTTP trigger functions?
AResponding to database changes
BServing dynamic web content
CHandling webhooks
DCreating REST APIs
What happens if you don't send a response in an HTTP trigger function?
AThe function times out and the client waits indefinitely
BThe function automatically sends a default response
CThe function logs an error but returns success
DThe function restarts automatically
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.