2
router.get("/(profile|setting)/:username", function (req, res) {

I am trying to achieve a route that will respond to

/profile/:username
/setting/:username

I am not sure how to embedded the expression inside the route. I am getting error with this example.

Zanko
  • 4,298
  • 4
  • 31
  • 54
  • 1
    *I am getting error with this example* => which error?. Also, see [Regex for route matching in Express](http://stackoverflow.com/questions/10858005/regex-for-route-matching-in-express) – Thomas Ayoub Jul 18 '16 at 14:58
  • The error that the regex expression is invalid. I finally fixed it! Apparently you have to do `/:type(profile|setting)`. I am not sure why you need like a dummy param variable in front. If anyone know please tell me! – Zanko Jul 18 '16 at 15:00
  • @Zanko just think, if you didn't have a variable there to catch the `profile` or `setting` route, how would you go back to the url parameters to check? – m_callens Jul 18 '16 at 15:12

0 Answers0