Skip to content

Tag: nestjs

NestJs async httpService call

How can I use Async/Await on HttpService using NestJs? The below code doesn`t works: Answer The HttpModule uses Observable not Promise which doesn’t work with async/await. All HttpService methods return Observable<AxiosResponse<T>>. So you can either transform it to a Promise and then use aw…

FileInterceptor doesn’t work

What am I doing wrong? file is undefined Answer The code works as expected in a fresh project. Hence, the dependencies are corrupt. Deleting the node_modules folder and running npm install solves the problem.

Decorator to return a 404 in a Nest controller

I’m working on a backend using NestJS, (which is amazing btw). I have a ‘standard get a single instance of an entity situation’ similar to this example below. This is incredibly simple and works – however, if the user does not exist, the service returns undefined and the controller ret…