I have and expressjs application and on a specific route I call a function that responds with a user from the database by calling res.json with the database doc
The json function loses its correct this binding when used like that since .then is going to invoke it directly without reference to the res parent object, so bind it:
var getUserInline = function(req, res) {
getUserFromDatabase().then(res.json.bind(res));
}