问题
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.
回答1:
response.end()
will set response.finished
if it's been called, as per the documentation.
回答2:
Use res.writableEnded
(docs).
res.finished
is deprecated (see).
来源:https://stackoverflow.com/questions/57618325/check-if-res-is-sent-ended-with-express