Request and response — Basics · Express

The request and the response in detail: answer JSON or CSV with res.format(), refuse a body that is not JSON with req.is(), remember a preference in a cookie with cookie-parser, and redirect to a resource that can move.

What you will learn

Read the theory for Request and response

All Basics lessons

All Express courses

loading types…

What you'll learn

  • Answer in the representation the client prefers with res.format(), including a default for none
  • Check a request body's type with req.is(), and read and set cookies with cookie-parser, res.cookie() and res.clearCookie()
  • Redirect with res.redirect(), choosing between a temporary and a permanent move