Reputation:
Using Express, how can I determine the response has been sent / that the response has been completely written to?
app.use((req,res,next) => {
if(res.ended){
//
}
if(res.finished){
//
}
});
how can I tell if res.end()
has been called? I am looking for a boolean I can read on res.
Upvotes: 7
Views: 11419
Reputation: 480
Use res.writableEnded
(docs).
res.finished
is deprecated (see).
Upvotes: 12
Reputation: 211580
response.end()
will set response.finished
if it's been called, as per the documentation.
Upvotes: 4