Tevin Thuku Tevin Thuku - 3 months ago 30
Javascript Question

Flow router Redirect On Data Insert Meteor js

Im using react , meteor and flow router. How do I redirect once data has been inserted to the database

This is the function I have

Meteor.call('insertQuestion', header, content,
usernameoremail,date,function(error){
if(error) {
show({text: error.reason, pos: 'bottom-left'});
}
else {
show({text: "Your Question Has been posted", pos: 'top-right'});
}
});


Which flow router function should I use?

Answer

FlowRouter.go(pathDef, params, queryParams);

This will get the path via FlowRouter.path based on the arguments and re-route to that path.

You can call FlowRouter.go like this as well:

FlowRouter.go("/blog");

You can check more about flow-router here

Meteor.call('insertQuestion', header, content,
 usernameoremail,date,function(error){
  if(error) {
    show({text: error.reason, pos: 'bottom-left'});
  }
  else {
    show({text: "Your Question Has been posted", pos: 'top-right'});
    FlowRouter.go(pathDef, params, queryParams)
  }
});
Comments