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

Pass data through window object history in Angular navigation

Code snippet showing how to add and retrieve data from window object history in Angular Continue reading