res.app
This property holds a reference to the express
application instance that is using the middleware.
index.js
'use strict' const express = require('express') const app = express() app.locals.name = 'Chat Application' app.locals.version = '1.2.31' app.get('/', (req, res) => { res.send('Hello World') }) app.get('/aboutMe', (req, res) => { var info = `Application Name : ${res.app.locals.name}<br /> Version : ${res.app.locals.version}` res.send(info) }) const port = 3000 app.listen(port, () => console.log(`Application started listening on port ${port}!`));
Run index.js
Open the url ‘http://localhost:3000/aboutMe’ in browser,
you will see below message.
No comments:
Post a Comment