-
Notifications
You must be signed in to change notification settings - Fork 2k
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
docs.nestjs.com/content/controllers.md
Lines 340 to 355 in 8f7a101
#### 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
Labels
No labels