Express.js Flashcards
What is a client?
A client is a requester of a service
What is a server?
A server provides a function or service to one or many clients
Which HTTP method does a browser issue to a web server when you visit a URL?
GET method
What is on the first line of an HTTPrequestmessage?
Method, Request Target, HTTP Version
What is on the first line of an HTTPresponsemessage?
HTTP Version, Status Code, Status Text
What are HTTP headers?
HTTP Headers let the client and server pass additional information with an HTTP request or response.
Is a body required for a valid HTTP message?
No
How do you addexpressto your package dependencies?
npm install express
What Express application method starts the server and binds it to a networkPORT?
listen() method
How do you mount a middleware with an Express application?
use() method
What objects do an Express application pass to your middleware to manage the request/response lifecycle of the server?
- Req object
- Res object
What does theexpress.json()middleware do and when would you need it?
It parses incoming requests with JSON payloads and attaches to body of req object
What is the significance of an HTTP request’s method?
Runs the code block
What is the appropriateContent-Typeheader for HTTP messages that contain JSON in their bodies?
Content-Type: application/json; charset=utf-8
What doesexpress.static()return?
A middleware function