Hi i have been reading the express js docs and i got this sentence but i dont understand what dose this means this sentense is :
When you use a regular expression for the route definition, capture groups are provided in the array using req.params[n]
please can you give me an example that clarifay this sentense for me
the link in docs is : https://expressjs.com/en/4x/api.html#req.params
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Hi there,
Let’s say that you have the following route:
/file/*
, this means that anything after the/file/
will match the*
wildcard regex.So if you receive a GET request to
/file/javascripts/jquery.js
, in order to access the parameter you can use a standard array syntax as follows:And the output in this case will be:
Hope that this helps!
Best,
Bobby