SkinnyG33k
SkinnyG33k

Reputation: 1731

Update Query Param with Iron Router

I'm trying to figure out the least brittle way to update a query param in Iron Router.
Flow-Router has FlowRouter.setParams({step: 2}) which is ideal.

Currently i'm using this but I wanted to check if there's a better way (especially since the IR API changes so frequently)

var currentId = Router.current().params.id;
var newStep = '2';
Router.go('checkout', {id: currentId}, {query: 'step=' + newStep});

Upvotes: 0

Views: 150

Answers (1)

saimeunt
saimeunt

Reputation: 22696

This is the correct way, but you can use the object syntax for the query just like in FlowRouter.

Router.go('checkout', {
  id: currentId
}, {
  query: {
    step: 2
  }
});

Upvotes: 1

Related Questions