app.on()

app.on('mount', callback(parent))

The mount event is fired on a sub-app, when it is mounted on a parent app. The parent app is passed to the callback function.

NOTE

Sub-apps will:

  • Not inherit the value of settings that have a default value. You must set the value in the sub-app.
  • Inherit the value of settings with no default value.

For details, see Application settings.

1
2
3
4
5
6
7
8
9
10
11
12
var admin = express();
 
admin.on('mount', function (parent) {
  console.log('Admin Mounted');
  console.log(parent); // refers to the parent app
});
 
admin.get('/', function (req, res) {
  res.send('Admin Homepage');
});
 
app.use('/admin', admin);
doc_Express
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.