CHAPTER 6

image

Response

The Express.js response object (res for short)—which is an argument in the request handler callbacks—is the same good old Node.js http.response object1 on steroids. This is because the Express.js response object has new methods. In other words, the Express.js response object is the extension of the http.response class.

Why would some use these additional methods? Indeed, you can use the response.end() method2 and other core methods, but then you'll have to do write more code. For example, you would have to add Content-Type header manually. But with the Express.js response object which contains convenient wrappers, such as

Get Express.js Deep API Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.