
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Disable Method
The app.disable() method disables the setting name passed in the function. This method sets the setting name to False. We can perform the same function by using the app.set() method too, by passing its value as False.
Syntax
app.disable(name)
Example 1
Create a file with the name "appDisable.js" and copy the following code snippet. After creating the file, use the command "node appDisable.js" to run this code.
// app.disable() 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; // Disabling the property foo app.disable('foo'); // Checking the foo property console.log(app.get('foo'));
Output
C:\home
ode>> node appDisable.js false
Example 2
Let’s take a look at one more example.
// app.disable() 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; // Disabling the property foo app.disable('trust proxy'); // Checking the foo property console.log("Trust proxy settings are set to: ", app.get('trust proxy'));
Output
C:\home
ode>> node appDisable.js Trust proxy settings are set to: false
Advertisements