I don't like using observables for http requests. I would like to see the "option" of using Promises. This issue sums up my feelings on the matter perfectly https://github.com/nestjs/nest/issues/471
I've created a HttpPromiseModule in my project that mirrors the HttpModule but without the Observable wrapping. This module is a lot easier to work with and matches the coding style on the backend better. I have a PR I can submit if you want to see the code.
You use it the exact same way as the HttpModule except you use the HttpPromiseModule
Observables for http feels wrong/overkill. Tired of adding .toPromise() on all my http requests.
You can just call .toPromise() on the observable, so I really don't see the issue here.
EDIT:
Didn't realize you mentioned this.
As mentioned here, our recommended way is to use Observable https://github.com/nestjs/nest/issues/471
If you want to use Promises, call .toPromise.
If you don't want to call .toPromise, you can wrap HttpService in, let's say, HttpPromiseService and just override methods, call .super() and add .toPromise() so you don't have to do it over and over again. Bringing 2 different modules for the sake of 1 method call is an overkill
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
As mentioned here, our recommended way is to use
Observablehttps://github.com/nestjs/nest/issues/471If you want to use Promises, call
.toPromise.If you don't want to call
.toPromise, you can wrapHttpServicein, let's say,HttpPromiseServiceand just override methods, call.super()and add.toPromise()so you don't have to do it over and over again. Bringing 2 different modules for the sake of 1 method call is an overkill