I'm using NestJS for my backend angular project and I've put method. It was running fine before I install swagger but after I install swagger, I got a warning that saying unhandled promise rejection and it won't allow me to run.
It's working fine If I comment the code in controllers so I think there is a problem with async/await but not really sure how to fix it so I would be really appreciated if I can get any help or suggestion on how to fix this?
Controller
@Put(':id')
async updateHelpSubsection(@Body() newHelp: HelpSubsectionModule, @Param() params): Promise<HelpSubsectionModule> {
try{
let oldHelpData = await this.helpSubsectionService.getHelpSubsectionbyId(params.id)
return this.helpSubsectionService.updateHelpSubsection(oldHelpData, newHelp);
}catch(e) {
console.log(e)
}
}
Services
async updateHelpSection(updateHelp: HelpSectionEntity, newHelpData): Promise<HelpSectionEntity> {
Object.keys(newHelpData).forEach((key) => {
updateHelp[key] = newHelpData[key];
});
try {
return await this.helpSectionRepo.save(updateHelp);
} catch (err) {
throw new HttpException({
error: err
}, HttpStatus.FORBIDDEN)
}
}
Please update this in the controller:
@Put(':id')
async updateHelpSubsection(@Body() newHelp: HelpSectionEntity, @Param() params): Promise< HelpSectionEntity> {
try{
let oldHelpData = await this.helpSubsectionService.getHelpSubsectionbyId(params.id)
return this.helpSubsectionService.updateHelpSubsection(oldHelpData, newHelp);
}catch(e) {
console.log(e)
}
}
Modules are not allowed in the types in typescript.
Please replace HelpSubsectionModule with HelpSectionEntity.