I'm currently utilizing NestJS for the backend of my Angular project, and I encountered an issue after installing Swagger. Prior to the installation, everything was running smoothly. However, post-installation, a warning about an unhandled promise rejection surfaced, preventing the application from running.
If I comment out the code in the controllers, the application works fine leading me to suspect there may be an issue with async/await. Unfortunately, I am unsure about how to address this problem. Therefore, any assistance or suggestions on resolving this would be greatly appreciated.
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)
}
}
This is the warning message I'm encountering: https://i.sstatic.net/wDECV.png