Complete the code to send a 201 status code in a NestJS controller method.
return response.status([1]).send('Created');
The status code 201 means 'Created'. It tells the client that a new resource was successfully created.
Complete the code to set a custom header 'X-Custom-Header' with value 'NestJS' in the response.
response.[1]('X-Custom-Header', 'NestJS');
send instead of set to set headers.setHeader which is not a NestJS response method.The set method sets headers in the response object in NestJS.
Fix the error in setting the status code and sending JSON response.
return response.[1](200).json({ message: 'OK' });
send to set status code causes errors.set or header instead of status.The status method sets the HTTP status code before sending the response.
Fill both blanks to set status 404 and a custom header 'X-Error' with value 'NotFound'.
return response.[1](404).[2]('X-Error', 'NotFound').send();
header instead of set for headers.send to set status code.Use status to set the status code and set to add headers.
Fill all three blanks to set status 204, add header 'X-Info' with 'No Content', and send the response.
return response.[1](204).[2]('X-Info', 'No Content').[3]();
json with 204 status which should have no body.header instead of set.Use status to set status, set to add header, and send to send the response.