Skip to content

why express does not implement Node.js style callbacks? #3250

@fluency03

Description

@fluency03

I have a question regarding the APIs. Why express does not implement Node.js style callbacks, i.e., Error-First Callbacks?

For example, router.METHOD:

router.get('/', function(req, res){
  res.send('hello world');
});

And furthermore, I also saw this Error handling:

app.use(function (err, req, res, next) {
  // logic
})

Then, my question is: after add the Error Handling middleware as above, can I regard my code as following?

router.get('/', function(err, req, res, next){
  res.send('hello world');
});

If so, I am able to use Q.denodeify converting the callback style to promise style right? Because Q.denodeify, as stated here, only deals with Node.js style (err, result) callback APIs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions