How can I use Async/Await on HttpService
using NestJs?
The below code doesn`t works:
async create(data) {
return await this.httpService.post(url, data);
}
As toPromise()
is being deprecated, you can replace it with firstValueFrom
or lastValueFrom
For example:
const resp = await firstValueFrom(this.http.post(`http://localhost:3000/myApi`)
https://rxjs.dev/deprecations/to-promise
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With