Sunday, 10 April 2022

NestJS: How to use async/awayt instead of RxJS in gRPC client code?

I have a set of NestJS micro-services which are written using async/await in their APIs. After adding gRPC, I am able to use async/await in the server implementation of gRPC APIs, however the client code would always return RxJS Observable. Because of this, I have to wrap gRPC method calls into firstValueFrom().

await firstValueFrom(this.orderService.getOrder({ orderId }));

I don't want to mix both paradigms, it is inconvenient, and it just adds redundant code. I went through the Nest gRPC documentation and could find any references on how to use async/await instead of RxJS in the client code. At the same time, if they allow using async/await in the server APIs, I assume it is somehow possible to do the same on the client side.

Q: How to use async/awayt instead of RxJS in gRPC client code in NestJS?



from NestJS: How to use async/awayt instead of RxJS in gRPC client code?

No comments:

Post a Comment