#How to use parameter decorator when developing with js
5 messages · Page 1 of 1 (latest)
Like all other parameter decorators when using babel and raw JS, you need to use @Bind().
Typescript Example:
@Get(':id')
findOne(@Param() params: any): string {
console.log(params.id);
return `This action returns a #${params.id} cat`;
}
Equivalent JS example:
@Get(':id')
@Bind(Param())
findOne(params) {
console.log(params.id);
return `This action returns a #${params.id} cat`;
}
So, in your case, to bind @UploadedFile() and @Req() you need to do @Bind(UploadedFile(), Req())
Thank you! Finally found a correct solution. I didn't find such usage in the official documents.
It's just extrapolation of what already exists. If @Body() can be used with @Bind(Body()) it makes sense that @UploadedFile() would be used in the same way