I’m trying to get different types of dtos from body. If firstDto is incoming get it and transform, if secondDto is incoming transform it to secondDto. But it’s not working and I have no idea. Here is my code;
@Controller('log')
export class LogsController {
constructor(private logsService: LogsService) {}
@Post()
async createStatusLog(@Body() body: CreateMessageDto | CreateStatusDto) {
console.log(body.constructor.name);
return body;
}
}
app.module.ts
providers: [
AppService,
{
provide: APP_PIPE,
useValue: new ValidationPipe({
whitelist: true,
transform: true,
}),
},
],