Skip to content

Documentation of "route" property of Request #1064

Description

@machineghost

This was moved from: expressjs/express#4033

It is regarding: http://expressjs.com/en/4x/api.html#req.route

The current description of the route property says (emphasis added):

Contains the currently-matched route, a string. For example:

However, it then shows "Example output from the previous snippet", and that previous snippet had only a single console.log in it: console.log(req.route).

One would expect to see a string logged, but what's logged instead is clearly an object:

{ path: '/user/:id?',
  stack:
   [ { handle: [Function: userIdHandler],
       name: 'userIdHandler',
       params: undefined,
       path: undefined,
       keys: [],
       regexp: /^\/?$/i,
       method: 'get' } ],
  methods: { get: true } }

It seems like of the two must be incorrect, and that the documentation should most likely say something like:

Contains the currently-matched route, an object with method, path, and stack properties. For example:

I'd be happy to PR this, but I don't know this property at all so I don't know if that is the correct fix.

Activity

  1. wesleytodd commented on Aug 22, 2019

    @wesleytodd
    Member

    Yes I think this is a correct change, and a PR to that effect would be great.

  2. locked and limited conversation to collaborators on Aug 2, 2025
  3. converted this issue into a discussion #2026 on Aug 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions