- 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
Express.js – app.disabled() Method
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.
Syntax
app.disabled( name )
Example 1
Create 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 router = express.Router(); var PORT = 3000; // Checking the foo property console.log("Is Settings disabled: ", app.disabled('trust proxy'));
Output
C:\home
ode>> node appDisabled.js Is Settings disabled: true
Example 2
Let's take a look at one more example.
// 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 router = express.Router(); var PORT = 3000; app.enable('trust proxy'); // Checking the foo property console.log("Is Settings disabled: ", app.disabled('trust proxy'));
Output
C:\home
ode>> node appDisabled.js Is Settings disabled: false
Advertisements