How to access path parameters from ExpressJS request

Select one parameter

router.get('/:userId/profile', async (request, response) => {
  const userId = request.params.userId;
 // ....
});

Select multiple path parameters

personalBookmarksRouter.get('/:bookmarkId', keycloak.protect(), async (request, response) => {
  const {userId, bookmarkId} = request.params;
  // ...
});

Reference - https://github.com/BookmarksDev/bookmarks.dev


Shared with from Bookmarks.dev. Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Subscribe to our newsletter for more code resources and news

Adrian Matei

Adrian Matei
Life force expressing itself as a coding capable human being

How to resize pictures from folder in Node.js with Jimp

Simple api tool implementation on localhost to resize from folder in Node.js with Jimp Continue reading