Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Redundant Promise return type on async handlers? #3312

Closed
@vjancik

Description

Every async function in JS / TS already returns a Promise. Is this example suggesting every async handler must return a promise that resolves into a promise or is it a wrong return type?

https://docs.nestjs.com/controllers#asynchronicity

#### Asynchronicity
We love modern JavaScript, especially its emphasis on **asynchronous** data handling. That’s why Nest fully supports `async` functions. Every `async` function must return a `Promise`, which allows you to return a deferred value that Nest can resolve automatically. Here's an example:
```typescript
@@filename(cats.controller)
@Get()
async findAll(): Promise<any[]> {
return [];
}
@@switch
@Get()
async findAll() {
return [];
}
```

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

        AltStyle によって変換されたページ (->オリジナル) /