Skip to content

onRequest in documentation doesn't produce the expected result #597

@Benliam12

Description

@Benliam12

What is the type of issue?

Documentation is Incorrect

What is the issue?

The code presented in the tutorial doesn't work when applied in the latest version of Elysia

// Global middleware
.onRequest(({ method, path }) => {
   console.log(`${method} ${path}`)
})

Using this, you will get undefined /whatEverPathWasTriggered

It should be updated to be using:

// Global middleware
.onRequest(({ request }) => {
   console.log(`${request.method} ${request.url}`);
})

To have the expected result.

This could be due to the latest version? Or perhaps an outdated documentation?

Where did you find it?

https://elysiajs.com/migrate/from-express.html#middleware

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions