res.headersSent
This property used to check whether response headers are
sent to the client or not.
index.js
'use strict' const express = require('express') const app = express() app.get('/', (req, res) => { console.log(`Is headers sent ? : ${res.headersSent}`) res.send('Hello World') console.log(`Is headers sent ? : ${res.headersSent}`) }) const port = 3000 app.listen(port, () => console.log(`Application started listening on port ${port}!`));
Run index.js
Open the url ‘http://localhost:3000/’ in browser, you can
see below messages in console.
Is headers sent ? : false
Is headers sent ? : true
No comments:
Post a Comment