6 thoughts on “Why is next() “not defined” inside the app.all route function?

  1. The next function is passed in as the 3rd param of the callback. You need to give it a name:

    app.all(‘*’, function(req, res, next) {

    On May 23, 2013, at 12:16 PM, trusktr notifications@github.com wrote:

    I’m doing this:

    app.all(“*”, function(req, res) {
    console.log(“\n\n————- BLAH ———\n\n”);
    next(); // Why doesn’t next() work here????????
    });
    And it says “ReferenceError: next is not defined” so I can’t move to the next route.

    Why?


    Reply to this email directly or view it on GitHub.

  2. @brainflake Oops, my brain flaked. That was obvious, and I’m tired from final exams at school. I’ll remember that next time!

    @Nami-Doc Forgetting to pass an argument to a function is (for the most part) language-independent and it doesn’t have much to do with JavaScript. For all you know, I might be better at JavaScript than you are, but I could care less if I am.

  3. I hope you are, I think I’m a pretty bad javascripter myself. But the error seems to be self-explanatory enough, so I thought you were just “trying to get express running” – don’t take offense. I spend quite some time on stackoverflow and this happens a lot : you want a better technology than the one you’re currently stuck with, but sometimes you just didn’t learn the host langage enough (ie: rails server-side, or … jquery haha).

    is (for the most part) language-independent

    To a certain extent … A lot of langages have most of their libraries with global state.

  4. nevertheless i think its a bad idea to tell people to stop doing what they are doing to learn something,
    even if its well intended advice.

    if somebody wants to learn anything the best approach to self taught learning imho is to have a project.
    it might end up badly implemented, it might not be usable at all,
    but having a goal is the most important part of learning to me and most self taught people in the hackspaces i know.

    dont take this as a personal attack, as said its just my humble opinion.

    keep on rocking you all,
    <3, have fun
    jascha

  5. nevertheless i think its a bad idea to tell people to stop doing what they are doing to learn something,
    even if its well intended advice.

    more like “know what you’re gonna have to deal with”, of course I wouldnt recommend learn another library or something in the middle of trying express

Comments are closed.