Recall & Review
beginner
What is the main purpose of creating documents in Express?
Creating documents in Express usually means generating and sending files like HTML, JSON, or PDFs as responses to client requests.
Click to reveal answer
beginner
Which Express method is commonly used to send JSON documents to the client?
The
res.json() method sends a JSON document as the HTTP response.Click to reveal answer
intermediate
How do you send an HTML document as a response in Express?
You can use
res.send() with an HTML string or use res.render() if you have a template engine set up.Click to reveal answer
intermediate
What is the role of middleware when creating documents in Express?
Middleware can process data, generate documents, or modify responses before sending them to the client.
Click to reveal answer
beginner
How can you serve a static document file like a PDF in Express?
Use
res.sendFile() with the file path to send static files like PDFs to the client.Click to reveal answer
Which Express method sends a JSON document as a response?
✗ Incorrect
res.json() sends JSON data as the HTTP response.
To send an HTML page using a template engine in Express, you use:
✗ Incorrect
res.render() renders a template and sends HTML to the client.
Which method is best to send a static PDF file to the client?
✗ Incorrect
res.sendFile() sends static files like PDFs.
Middleware in Express can be used to:
✗ Incorrect
Middleware can modify or generate responses before sending documents.
Which method sends a plain string or HTML directly as a response?
✗ Incorrect
res.send() sends strings or buffers as responses.
Explain how you would send a JSON document and an HTML document in Express.
Think about the response methods for different content types.
You got /3 concepts.
Describe how middleware can help when creating and sending documents in Express.
Middleware acts like a helper in the request-response cycle.
You got /3 concepts.