- 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
Found 72 Articles for Express JS
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
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, use the command "node appDisabled.js" to run this code as shown in the example below −// app.disabled() Method Demo Example // Importing the express module const express = require('express'); // Initializing the express and port number var app = express(); // Initializing the router from express var ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
768 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 the following code snippet. After creating the file, use the command "node reqMethod.js" to run this code as shown in the example below −// req.method Property Demo Example // Importing the express & cookieParser module var cookieParser = require('cookie-parser'); var express = require('express'); // Initializing the express and ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
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 the following code snippet. After creating the file, use the command "node routerRoute.js" to run this code as shown in the example below −// router.route() Method Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
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" and copy the following code snippet. After creating the file, use the command "node resAttachment.js" to run this code as shown in the example below −// res.attachment() Method Demo Example // Importing the express var express = require('express'); // Initializing the express and port number var app = ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
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" and copy the following code snippet. After creating the file, use the command "node reqParams.js" to run this code as shown in the example below −// req.params Property Demo Example // Importing the express var express = require('express'); // Initializing the express and port number var app = ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
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 // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); // Initializing the router from express var router = express.Router(); var PORT = 3000; // Defining an endpoint and checking req.route app.get('/api', function (req, res) { ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
660 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 snippet. After creating the file, use the command "node resLocation.js" to run this code as shown in the example below −// res.location(path) Method Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); // Initializing ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
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 the proxy.Syntaxreq.protocolExample 1Create a file with the name "reqProtocol.js" and copy the following code snippet. After creating the file, use the command "node reqProtocol.js" to run this code as shown in the example below −// req.protocol Property Demo Example // Importing the express module var express = require('express'); ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
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, authenticated user, etc.Syntaxres.localsExample 1Create a file with the name "resLocals.js" and copy the following code snippet. After creating the file, use the command "node resLocals.js" to run this code as shown in the example below −// res.locals Property Demo Example // Importing the express module var express = require('express'); ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
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 run this code as shown in the example below −// res.links(links) Method Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); // Initializing the router from express var router = express.Router(); var PORT = ... Read More