Next-routes: Push or replace route with query params

Created on 26 Dec 2018  路  5Comments  路  Source: fridays/next-routes

Can I use pushRoute or replaceRoute and specify query parameters via json object?

Most helpful comment

You can specify query parameters by passing an object in pushRoute or replaceRouter
let params = {a: '1', b: '2', c: '3'}
Router.pushRoute('routeName', params)

In pushRoute the first paramter will be the name of the route defined in your router file

All 5 comments

I've come across this issue too

You can specify query parameters by passing an object in pushRoute or replaceRouter
let params = {a: '1', b: '2', c: '3'}
Router.pushRoute('routeName', params)

In pushRoute the first paramter will be the name of the route defined in your router file

The Documentation specifies that a URL can be used, however i only seem able to get the it working when i use the route-name as @antiproblemist suggested above.

API:
Router.pushRoute(route)
Router.pushRoute(route, params)
Router.pushRoute(route, params, options)

Arguments:
route - Route name or URL to match

Hi @haotangio.

I think that this is the point

https://github.com/fridays/next-routes/blob/master/src/index.js#L172

Nested Objects needs to stringified by qs

@theshaune When route is resolved by URL, there's no params argument.
Authors answer on issue: https://github.com/fridays/next-routes/issues/75#issuecomment-314796343

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mocheng picture mocheng  路  5Comments

adekbadek picture adekbadek  路  4Comments

breeny picture breeny  路  5Comments

jesstelford picture jesstelford  路  3Comments

adrianha picture adrianha  路  3Comments