Quantcast
Viewing all articles
Browse latest Browse all 37

Does the Nestjs controller method have to be async if it returns a promise?

Very simple general question:

@Controller('something')class SomeController {  @Get()  foobar() {     return foo() // this returns a promise  }}

So in such a case, do I have to make the foobar() controller method async?My understanding is that this is not necessary. NestJS will resolve the returned promise automatically. Making the method async is only needed if I wanna await inside.

Is this correct?


Viewing all articles
Browse latest Browse all 37

Trending Articles