Insomnia has an environment you can set baseurl and port
also sub environments
MIDDLEWARE
express has a built-in body-parser:
express.json uses body-parser as middleware
and support lotsa other middleware
https://expressjs.com/en/resources/middleware.html
each packet contains: header, data, checksum
https://en.wikipedia.org/wiki/Transmission_Control_Protocol
express doesn’t know how to read the body content so the header informs it of the content type, and it uses a parser to convert it to a JSON object
router is instance of app (has same methods), BUT
cannot be used in testing, use:
forms uses either:
application/x-www-form-urlencoded or multipart/form-data (for images)
sent through header as content-type
app.use(express.urlencoded()); to parse the form data
errorhandler middleware MUST take in 4 params:
https://expressjs.com/en/guide/using-middleware.html#middleware.error-handlingapp.use(function(err, req, res, next)=>{})