I want to mention one important point regarding req.query because I am currently working on pagination functionality based on req.query and I have one interesting example to demonstrate to you ...
Example:
You req.query.pageSize + sign before req.query.pageSize and req.query.currentPage
What for? If you delete + in this case, you will get an error, and this error will be generated, because we will use an invalid type (with the error message, the "limit" field must be numeric).
Important Note : By default, if you extract something from these query parameters, it will always be a string , because it follows the URL and is treated as text.
If we need to work with numbers and convert query operators from text to numbers, we can simply add a plus sign in front of the operator.
Mile Mijatovic Apr 08 '19 at 19:42 2019-04-08 19:42
source share