The Be Sure Blog

Code Snippets | Problem Solving | Tips & Tricks

The Be Sure Blog banner

Read url parameters in Node.js/Express

posted on 22.2.2023 by Below Surface in "Node.js"

Assuming the URL is something like:

http://localhost:5000/uploads?userId=63f2642a765785448b65g5f1

And we want to read the userId in our Node.js/Express backend, this can be achieved with

req.query.userId

In action:

router.get("/", async (req, res) => {
  const userId = req.query.userId;
  console.log(userId);
});            

Tags:

node.js
express
parameters
params

Sources:

https://stackoverflow.com/questions/17007997/how-to-access-the-get-parameters-after-in-express

More posts of this category

Fixing the issue of rotated images after resizing with sharp

When resizing images with sharp, some pictures may be rotated afterwards

Node.js