0

I am trying to make an URL which accepts a query after "?" operator , which will looks like this "/search?q=" . The question how should I make this particular URL in express JS and also how I can integrate an "&" operator in it .

1 Answers1

0

You just need to register a route /search and all query parameters will be in req.query. It supports & for several parameters as well as a parameter with several values like this ?q=1&q=2&q=3.

Anatoly
  • 20,799
  • 3
  • 28
  • 42
  • This is if we want to get the requested query by user but I want to register parameter in url "/search?q=" . So in express , how should I write , app.get("/search?q=" , (req,res)) -->something like that or it will be wrong ?? –  Jan 27 '22 at 07:03
  • You don't need to register query parameters because they are dynamic. Just register `/search` and look at `req.query` – Anatoly Jan 27 '22 at 14:34