Reading the documentation, here is the signature of res.send
:
res.send(body|status[, headers|status[, status]])
Which means you can set your own status, like this: res.send( 'some string', 200 );
or even just res.send( 404 );
.
This method is the one you use to send the response.
Once it is sent to the client, you can't access it anymore, so there is no callback.
This is the last thing your server does. Once it has processed the request, it sends the response.
However, you can access it before you send it to the client. Which means you can:
console.log( res );
res.send( datas );
If you want to rollback/commit, you do it when the database's callback is called, not when the response is gone.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…