0

The following gives the output of the url/id.

app.get('/:id', function(req, res) {
   res.send('with slash' + req.params.id);
});

However, when I'm dealing with multiple slashes in the URL, I'm unable to get the id. For example, I want url/id1/id2/etc.../id. What should I put in place of the /:id for this?

Zuberi
  • 35
  • 6
  • 1
    So do you mean that you're trying to access a parameter *after* a parameter whose value should contain a forward slash (`/`)? E.g. in `/foo/bar/123`, you want `foo/bar` separately and `123` separately? – cbr May 25 '20 at 18:29
  • 1
    If so, does this answer your question? [*Express.js route parameter with slashes*](https://stackoverflow.com/q/16829803/996081) – cbr May 25 '20 at 18:31
  • @cbr Yes, it should be able to handle `/foo/bar/123` or `/foo/bar/foo/bar/123`, and provide 123 separately and the other part separately. – Zuberi May 25 '20 at 18:33
  • @cbr Yes, it does answer my question... thanks! – Zuberi May 25 '20 at 18:34

1 Answers1

0

You can use multiple parameters in your URL.

/:id1/:id2
Brad
  • 159,648
  • 54
  • 349
  • 530