express Flashcards

1
Q

why do you need body parser

A

in express, req implemented the ReadableStream

body-parser extracts the entire body portion of an incoming request stream and exposes it on req.body.

the body data is the stream content.

you need to to conver the stream content into Javascript object in req.
if it’s written in JSON, you need parse it with JSON.parse

if it’s URL-encoded, you will use some other approach to do the parsing.

JSON body parser
Raw body parser
Text body parser
URL-encoded form body parser

https://stackoverflow.com/questions/38306569/what-does-body-parser-do-with-express#:~:text=In%20order%20to%20get%20access,object%20that%20we%20can%20understand.

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

form data multipart content?

A

–«boundary_value»
Content-Disposition: form-data; name=”«field_name»”

«field_value»

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