Mayank Agarwal has Published 380 Articles

res.location() Method in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 08:18:32

662 Views

The res.location() method is used for setting the response Location HTTP header to the specified path parameter. Setting the location does not end the process, one can still send some response after setting the location header.Syntaxres.location( path )Example 1Create a file with the name "resLocation.js" and copy the following code ... Read More

req.protocol Property in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 08:15:20

412 Views

The req.protocol property returns the request protocol string that is either http or (for TLS requests) https. The value of X-Forwarded-Proto header field is used if present, when the passed trust proxy setting does not evaluate to False. This header values can be set either by the client or by ... Read More

res.links() Method in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 08:07:18

381 Views

The res.links() method is used for joining two links that are provided as properties of the parameter to populate the response’s Link HTTP header value.Syntaxres.links( links )Example 1Create a file with the name "resLinks.js" and copy the following code snippet. After creating the file, use the command "node resLinks.js" to ... Read More

res.locals Property in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 08:06:13

6K+ Views

The res.locals is an object that contains the local variables for the response which are scoped to the request only and therefore just available for the views rendered during that request or response cycle.This property is useful while exposing the request-level information such as the request path name, user settings, ... Read More

router.use() Method in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 07:45:17

2K+ Views

The router.use() method has an optional mount path which is set to "/" by default. This method uses the specified middleware functions for this optional mountpath. The method is similar to app.use().Syntaxrouter.use( [path], [function, ...] callback )Example 1Create a file with the name "routerUse.js" and copy the following code snippet. ... Read More

res.vary() Method in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 07:42:21

227 Views

The res.vary() method can be used for adding the field to the Vary response header, if the field does not already exist there. The vary header is basically used for content negotiation.Syntaxres.vary( field )Example 1Create a file with the name "resVary.js" and copy the following code snippet. After creating the ... Read More

req.hostname Property in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 07:39:19

1K+ Views

The req.hostname contains the hostname that is derived from the host HTTP header. This property will get its value from the X-Forwarded-Host header field when the trust setting properties are enabled (or not set to false). This header can be set by the client or by the proxy.The value of ... Read More

res.cookie() Method in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 07:35:09

6K+ Views

The res.cookie() method is used for setting the cookie name to value. The value parameter can be a string or an object converted to JSON.Syntaxres.cookie( name, value, [options] )ParametersThe options parameter can have the following values −domain − It represents the domain name of the cookie. Default refers to the ... Read More

req.fresh Property in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 07:32:45

246 Views

The req.fresh property returns True or false based upon the status of the client's cache. If the cache is still fresh, True is returned, else False will be returned to indicate that the cache is stale and all the content needs to be sent instead of just non-cached part.When a ... Read More

router.all() Method in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 07:30:53

421 Views

The router.all() method matches all the HTTP Methods. This method is mainly used for mapping "global" logic for specific path prefixes and arbitrary matches.Syntaxrouter.all( path, [callback, ...] callback )Example 1Create a file with the name "routerAll.js" and copy the following code snippet. After creating the file, use the command "node ... Read More

Advertisements