Search code examples
javascriptmeteoriron-router

Meteor Route dispatch never rendered warning


For route:

Router.route('/logout', function(){
    var self = this;
    Meteor.logout(function(err) {
        if (err) {
            console.log('Error loggin out!');
        }
        self.redirect('/');
    });
});

I receive this warning:

Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?

What is problem?


Solution

  • It can take time to log the user out. You need a template to display during this. A route cannot exist without a template with iron router. Or at least iron router is not designed to work without one.

    Your html:

    <template name="logout">
        Logging you out. Please wait...
    </template>
    

    Your route:

    Router.route('/logout', function(){
        Meteor.logout(function(err) {
            if (err) console.log('Error loggin out!');
            Router.go("/")
        });
    
        this.render("logout"):
    });