I'm using Nest framework and trying to make a Post request that gets a file and data here's what I did
@Post('upload')
@UseInterceptors(FileInterceptor('file'))
uploadFile(@Body('data') addRefundDto:AddRefundDto,@UploadedFile() file) {
console.log(addRefundDto);
console.log(addRefundDto.price);
console.log(addRefundDto.refundType);
return ' ';
}
which prints :
{ "refundType":"test", "currency":"usd", "price":58.5, "flightId":4, "iAiCard":true }
undefined
undefined
It's like the dto gets the json as text (I also tried calling @Body()instead of @Body('data'))
I removed "Content-Type","application/json" from the request in PostMan so I can upload the file, is there anyway to solve this nicely ?
Thanks a lot !