简体   繁体   中英

Flowrouter - have to reload whole page for route to be recognised

Quite basic setup - user submits a post, it's inserted by a method, then user should be routed to a confirm page with the _id of the newly created post:

const onSubmitPost = (post) => {
      createPost.call(post, (err, res) => {
        if(err) {
          instance.errorMessage.set(err.reason);
        } else {
          FlowRouter.go("create-post/:postId/confirm", { postId: res });
      }
   });
};

// Route definition    
FlowRouter.route("/create-post/:postId/confirm", {
  name: "create-confirm",
  action() {
    BlazeLayout.render("MainPage", { content: "ConfirmPostContainer" });
  }
});

But when I try this, I get There is no route for the path: create-post/abc123/confirm

If I manually press reload, it works fine - no problems.

Anyone have any idea what's going on, and how to fix?

EDITS

  • This is called on the /create-post route - redirect to confirm the post after it's created
  • Added route definition
  • Tried using redirect instead of go - no difference

There are 2 things I can suggest you to try. My hunch is that the problem stems from calling the .go method from /create-post with a relative path.

So, first, try route-names instead: FlowRouter.go('create-confirm', { postId: res });

Second, try absolute paths: FlowRouter.go('/create-post/' + res + '/confirm'); - notice the leading slash / !

Does that work?

尝试FlowRouter.redirect(您的路线名称,{postId:res}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM