HTTP / Express.js Flashcards
What is a client?
A device that requests services from a server.
What is a server?
A device that provides services to clients.
Which HTTP method does a browser issue to a web server when you visit a URL?
The GET method.
What three things are on the start-line of an HTTP request message?
HTTP method, the request target, and the HTTP version.
What three things are on the start-line of an HTTP response message?
HTTP version, status code, and status text.
What are HTTP headers?
Key value pairs that allow the client and server to pass additional information in an HTTP request or response.
Where would you go if you wanted to learn more about a specific HTTP Header?
MDN
Is a body required for a valid HTTP request or response message?
No.
How do you add express to your package dependencies?
npm install express
What Express application method starts the server and binds it to a network PORT?
express.listen(portNumber, callBack);
How do you mount a middleware with an Express application?
express.use((req, res, next) => {
code block here
})
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
req, res, and next
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
What does the express.json() middleware do and when would you need it?
The middleware function parses posted JSON strings from requests and adds them as the req.body object. You would need it whenever the server deals with JSON input.
What is the significance of an HTTP request’s method?
The significance is for humans, servers can technically be programmed to respond in any way possible to HTTP request methods.