Quantcast
Viewing latest article 14
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 latest article 14
Browse Latest Browse All 37

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>