typescript – Nest Js RabbitMQ payload attributes are undefined
I am trying to send message to my database microservice to get a page containing all existing results. To do this I am using a Pageable object which have skip and take attributes but they seems to be undefined separately but not within the pageable object.
db microservice controller:
@MessagePattern('song.find.all')
async findAll(@Payload() pageable: { take: number, skip: number }): Promise<Page<Song>> {
console.log(pageable);
console.log(pageable.take, pageable.skip);
this.logger.log(`Received song.find.all take: ${pageable.take} skip: ${pageable.skip} message`);
return await this.songService.findAll(pageable);
}
The log is the following:
{ pageable: { take: 10, skip: 0 } }
undefined undefined
api microservice controller:
@Get()
getSongs(
@Query('take') take: string,
@Query('skip') skip: string,
): Observable<Page<Song>> {
return this.apiGatewayService.findSongs({
take: parseInt(take, 10),
skip: parseInt(skip, 10),
});
}
Read more here: Source link
