-
Book Overview & Buying
-
Table Of Contents
Nest.js: A Progressive Node.js Framework
By :
Nest.js provides two approaches for generating responses.
Using the standard and recommended approach, which has been available since Nest.js 4, Nest.js will automatically serialize the JavaScript object or array returned from the handler method to JSON and send it in the response body. If a string is returned, Nest.js will just send the string without serializing it to JSON.
The default response status code is 200, expect for POST requests, which uses 201. The response code for can easily be changed for a handler method by using the @HttpCode(...) decorator. For example:
@HttpCode(204)@Post()create() {// This handler will return a 204 status response}
An alternate approach to generating responses in Nest.js is to use a response object directly. You can ask Nest.js to inject a response object into a handler method using the @Res() decorator. Nest.js uses express response objects].
You can rewrite the response handler...
Change the font size
Change margin width
Change background colour