fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

Parameters vs Query #36

Closed nishtacular closed 7 years ago

nishtacular commented 7 years ago

Hey guys, I'm trying to resolve an issue and was hoping for some help. When navigating to a sub route from the client I am getting the sku field as query string, but I need it as a parameter. It works as a parameter on server load but not client. Example

<Link route='product' params={{sku:product.sku}}><a>Product 1</a></Link>
<Link route='product' params={{sku:product.sku}}><a>Product 2</a></Link>

Now if I load this url /product/123 directly it works and loads the correct page. However, if I am on another page and click on the links above the url read /product?sku=123. I need both links to the the former. How can I get this fixed. Appreciate any pointers.

nishtacular commented 7 years ago

Sorry, guys I figured it out. Must be the lack of sleep playing tricks 😳

supra28 commented 7 years ago

@nishtacular What was the problem here ?

nishtacular commented 7 years ago

@supra28 Not sure if you're still after an answer but from memory i wasn't including the sku in route definition. See example below

routes.add('product', '/product'); // the WRONG way
--
routes.add('product', '/product/:sku?');