meteor - object is not a function in iron-router routes at onBeforeAction hook's this.next() -
i'm running iron-router 1.0.7, , onbeforeaction
hook causing exception. here's stack trace:
exception in callback of async function: typeerror: object not function @ router.onbeforeaction.except (http://localhost:3000/lib/router.js?ebfe803416134e7c5b16265486b3998532289c58:45:8) @ http://localhost:3000/packages/iron_router.js?a427868585af16bb88b7c9996b2449aebb8dbf51:1199:36 @ _.extend.withvalue (http://localhost:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:955:17) @ router.addhook.hookwithoptions (http://localhost:3000/packages/iron_router.js?a427868585af16bb88b7c9996b2449aebb8dbf51:1198:27) @ boundnext (http://localhost:3000/packages/iron_middleware-stack.js?0e0f6983a838a6516556b08e62894f89720e2c44:424:31) @ meteor.bindenvironment (http://localhost:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:983:22) @ router.onbeforeaction.only (http://localhost:3000/lib/router.js?ebfe803416134e7c5b16265486b3998532289c58:28:12) @ http://localhost:3000/packages/iron_router.js?a427868585af16bb88b7c9996b2449aebb8dbf51:1199:36 @ _.extend.withvalue (http://localhost:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:955:17) @ router.addhook.hookwithoptions (http://localhost:3000/packages/iron_router.js?a427868585af16bb88b7c9996b2449aebb8dbf51:1198:27)
and here hooks referenced:
router.onbeforeaction(function () { //check if it's logged in user if (!meteor.userid()) { //if aren't redirect them login this.render('login'); } else { //if let them through this.next(); } }, //the routes want if logged in check {only: ['profile', 'logout', 'users'] }); // redirects users survey until have answered questions router.onbeforeaction(function() { meteor.subscribe('questions'); var answered = getuseranswers(); var unanswered = questions.find({ _id: { $nin: answered } }, {sort: {priority: 1}}).count(); if (unanswered && roles.userisinrole(meteor.user(), 'manage-users')) { this.next(); } else if (unanswered) { this.redirect('survey'); } this.next(); }, {except: ['survey', 'passwordreset', 'logout', 'settings', 'login']});
it seems last this.next()
that's causing exception (that's line referenced in first line of trace.), can't tell why. if put breakpoint on in devtools, runs twice fine. then, on third stop, next
undefined. idea why happening? routes still seem work despite exception.
Comments
Post a Comment