express Flashcards

1
Q
  1. How do you add express to your package dependencies?
A

a. $ npm install express vs. $npm install express –save

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. What Express application method starts the server and binds it to a network PORT?
A

c. The app.listen() function is used to bind and listen the connections on the specified host and port.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. How do you mount a middleware with an Express application?
A

a. Use the use method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
A

a. The request object (req) and the response object (res).
b. Req is a data model of the HTTP request message (FROM the client)
c. Res: a data model of the HTTP response message (TO the client)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
A

a. ContentType: application/json
b. res.json([body])
c. This method sends a response (with the correct content-type) that is the parameter converted to a JSON string using JSON.stringify().
d. The parameter can be any JSON type, including object, array, string, Boolean, number, or null, and you can also use it to convert other values to JSON.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. What does the express.json() middleware do and when would you need it?
A

answer needed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. What is the significance of an HTTP request’s method?
A

a. HTTP defines a set of request methods to indicate the desired action to be performed for a given resource.
b. (this falls under the category of Rest API’s – structuring API’s so the way….
i. Get, post, delete, update (by using put (will replace the entire thing) or patch (will not replace the entire thing.))
c. The most commonly used HTTP request methods are GET, POST, PUT, PATCH, and DELETE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. What is the significance of an HTTP request’s method?
A

a. HTTP defines a set of request methods to indicate the desired action to be performed for a given resource.
b. (this falls under the category of Rest API’s – structuring API’s so the way….
i. Get, post, delete, update (by using put (will replace the entire thing) or patch (will not replace the entire thing.))
c. The most commonly used HTTP request methods are GET, POST, PUT, PATCH, and DELETE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly