Mayank Agarwal has Published 373 Articles

res.cookie() Method in Express.js

Mayank Agarwal

Mayank Agarwal

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

8K+ 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

309 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

562 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

req.cookies Property in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 07:25:51

2K+ Views

The req.cookies contains the cookies sent by the request while using the cookie-parser middleware. If the cookies are signed, please use the req.signedCookies property.Syntaxreq.cookiesInstall the cookie-parser module −npm install cookie-parserExample 1Create a file with the name "reqCookies.js" and copy the following code snippet. After creating the file, use the command ... Read More

res.append() Method in Express.js

Mayank Agarwal

Mayank Agarwal

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

1K+ Views

The res.append() method can append a specified value to the HTTP response header field. It creates new headers with the specified values, if it's not already created. The value string can take both a string input or an array.Syntaxres.append( field, [value] )Example 1Create a file with the name "resAppend.js" and ... Read More

res.app Property in Express.js

Mayank Agarwal

Mayank Agarwal

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

277 Views

The res.app property holds a reference to the instance of an Express Application that is being used by the middleware.Syntaxres.appExample 1Create a file with the name "resApp.js" and copy the following code snippet. After creating the file, use the command "node resApp.js" to run this code as shown in the ... Read More

req.path Property in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 07:15:56

2K+ Views

The req.path property contains the path part of the requested URL. This property is widely used to track the incoming requests and their paths. It is mainly used for logging the requests.Syntaxreq.pathExample 1Create a file with the name "reqPath.js" and copy the following code snippet. After creating the file, use ... Read More

app.enabled() Method in Express.js

Mayank Agarwal

Mayank Agarwal

Updated on 29-Jan-2022 07:11:22

226 Views

The app.enabled() method checks whether a setting name property is enabled or not. It basically checks the value of a setting name and returns True if the property value is also True.Syntaxapp.enabled( name )Example 1Create a file with the name "appEnabled.js" and copy the following code snippet. After creating the ... Read More

Node.js - dnsPromises.getServers() Method

Mayank Agarwal

Mayank Agarwal

Updated on 17-Jan-2022 13:21:31

87 Views

The dnsPromises.getServers() method returns an array of IP address strings, formatted across RFC 5952. These IP strings are currently configured for DNS configurations. The string will include a port only if a custom port is used.SyntaxdnsPromises.getServers( )Example 1Create a file with the name "getServers.js" and copy the following code snippet. ... Read More

Node.js - process.disconnect() Method

Mayank Agarwal

Mayank Agarwal

Updated on 17-Jan-2022 13:13:53

673 Views

When a Node.js process is spawned with an IPC channel, the process.disconnect() method will close that IPC channel to the parent process, allowing the child process to exit or finish gracefully. The process will exit once there are no other connections keeping it alive.Syntaxprocess.disconnect()Example 1Create two files with the names ... Read More

Advertisements