91-9990449935 0120-4256464 |
Express.js Response ObjectThe Response object (res) specifies the HTTP response which is sent by an Express app when it gets an HTTP request. What it does
Response Object PropertiesLet's see some properties of response object.
Response Object MethodsFollowing are some methods: Response Append methodSyntax: This method appends the specified value to the HTTP response header field. That means if the specified value is not appropriate then this method redress that. Examples: Response Attachment methodSyntax: This method facilitates you to send a file as an attachment in the HTTP response. Examples: Response Cookie methodSyntax: This method is used to set a cookie name to value. The value can be a string or object converted to JSON. Examples: Response ClearCookie methodSyntax: As the name specifies, the clearCookie method is used to clear the cookie specified by name. Examples: To set a cookie To clear a cookie: Response Download methodSyntax: This method transfers the file at path as an "attachment" and enforces the browser to prompt user for download. Example:Response End methodSyntax: This method is used to end the response process. Example: Response Format methodSyntax: This method performs content negotiation on the Accept HTTP header on the request object, when present. Example: Response Get methodSyntax: This method provides HTTP response header specified by field. Example: Response JSON method:Syntax: This method returns the response in JSON format. Example: Response JSONP methodSyntax: This method returns response in JSON format with JSONP support. Examples: Response Links methodSyntax: This method populates the response?s Link HTTP header field by joining the links provided as properties of the parameter. Examples: Response Location methodSyntax: This method is used to set the response location HTTP header field based on the specified path parameter. Examples: Response Redirect methodSyntax: This method redirects to the URL derived from the specified path, with specified HTTP status Examples: Response Render methodSyntax: This method renders a view and sends the rendered HTML string to the client. Examples: Response Send methodSyntax: This method is used to send HTTP response. Examples: Response sendFile methodSyntax: This method is used to transfer the file at the given path. It sets the Content-Type response HTTP header field based on the filename's extension. Examples: Response Set methodSyntax: This method is used to set the response of HTTP header field to value. Examples: Response Status methodSyntax: This method sets an HTTP status for the response. Examples: Response Type methodSyntax: This method sets the content-type HTTP header to the MIME type. Examples:
Next TopicExpressJS GET
|