Skip to content

Add generic type to return of json #142

@rtritto

Description

@rtritto

🆒 Your use case

The behaviour of

event.req.json<{ key: string }>()

should be

json: <T = any>() => Promise<T>

🆕 The solution you'd like

event.req.json() returns Promise<Body> where Body is inferred from EventHandlerRequest["body"] via TypedServerRequest → fetchdts's TypedRequest<Body, Headers>

🔍 Alternatives you've considered

No response

ℹ️ Additional info

Related: h3js/h3#1256

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions