- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Mayank Agarwal has Published 380 Articles
Mayank Agarwal
751 Views
The res.set() method can be used for setting the response's HTTP header field to value. You can also set multiple fields at once by passing an object as the parameter.Syntaxres.set( field, [value] )Example 1Create a file with the name "resSet.js" and copy the following code snippet. After creating the file, ... Read More
Mayank Agarwal
334 Views
The req.is() method is used for returning the matching content-type. It returns the matching content-type when the incoming request's "Content-type" HTTP header matches with those of the MIME type specified by the type parameter. If the request has no body, then it returns NULL, else it returns False.Syntaxreq.is( type )The ... Read More
Mayank Agarwal
155 Views
An application needs to maintain the remote client address for managing the number of requests from a computer system and tracking its usage. But sometimes, the server runs behind an NGINX server, so we need to check its forward request. For this purpose, we can use "x-forwarded-for"Syntaxreq.headers['x-forwarded-for'] || req.socket.remoteAddressIf the ... Read More
Mayank Agarwal
430 Views
The res.jsonp() method sends the json response with JSONP support. This method is similar to the res.json() method with the only difference being that it provides the JSONP callback support.Syntaxres.jsonp ( [body] )Example 1Create a file with the name "resJsonp.js" and copy the following code snippet. After creating the file, ... Read More
Mayank Agarwal
190 Views
The app.disabled() method checks and returns True if the property name passed is set to False or is disabled. If not, we can disable the property by using the app.disable() method.Syntaxapp.disabled( name )Example 1Create a file with the name "appDisabled.js" and copy the following code snippet. After creating the file, ... Read More
Mayank Agarwal
769 Views
The req.method property contains a string that corresponds to the HTTP methods of the request which are GET, POST, PUT, DELETE, and so on...These methods are based upon the requests sent by the user. All the above methods have different use-cases.Syntaxreq.methodExample 1Create a file with the name "reqMethod.js" and copy ... Read More
Mayank Agarwal
1K+ Views
The router.route() method returns the instance of a single route which can be used to handle the HTTP verbs further with the optional middleware. This method can be used to avoid duplicate route naming and therefore the typing errors.Syntaxrouter.route( path )Example 1Create a file with the name "routerRoute.js" and copy ... Read More
Mayank Agarwal
989 Views
The res.attachment() method is used for setting the Content-Disposition header field to "attachment". If a filename is passed, then it sets the Content-type based on the extension name that is retrieved from the res.type(). It sets the Content-Disposition "filename" field with the parameter.Syntaxres.attachment()Example 1Create a file with the name "resAttachment.js" ... Read More
Mayank Agarwal
7K+ Views
The req.params property is an object that contains the properties which are mapped to the named route "parameters". For example, if you have a route as /api/:name, then the "name" property is available as req.params.name. The default value of this object is {}.Syntaxreq.paramsExample 1Create a file with the name "reqParams.js" ... Read More
Mayank Agarwal
275 Views
The req.route property contains the recently matched route in a string format.Syntaxreq.routeExample 1Create a file with the name "reqRoute.js" and copy the following code snippet. After creating the file, use the command "node reqRoute.js" to run this code as shown in the example below −// req.route Property Demo Example ... Read More