Robertino Vasilescu
Robertino Vasilescu

Reputation: 1078

In sailsjs a route is matched but results in 404 with action not being called

I have this route

GET /shops/:id(\d+)-:shop': { action: 'shops/view-shop'}

In the 'shops/view-shop' fn I have just a console.log{'testing...'}

In the view I have this link example.com:1337/shops/6-shop-name The route is matched as regexp but somehow the action 'shops/view-shop' is not running and I get 404.

Any idea of why?

Upvotes: 1

Views: 47

Answers (1)

Robertino Vasilescu
Robertino Vasilescu

Reputation: 1078

A few minutes later, found the reason, the culprit was the

(\d+)

modifier. Without it the route works.

Surprisingly (for me) is that I have tested this route matching with the Express route testing and it worked.

I still have to see why not with the sailsjs routing.

EDIT:

I suppose that adding both an ID param and a (\d+) was not a bright idea.

Looking into the ration app that the sails creator meant it as a study I see that the "id" param is just like that, an "id" not a number with regexp.

So, I leave mine as it is.

Upvotes: 1

Related Questions