DEV Community

Discussion on: Building a RESTful API with NestJS and MongoDB (Mongoose)

Collapse
 
aliiiimansour94 profile image
Ali Mansour

hi buddy, when we are using: async function(....) { return await ..... },
should we add Promise or not? (like below):
async func(....): Promise {
return await ......
}

Collapse
 
carlomigueldy profile image
Carlo Miguel Dy

Hey, yea it's good too if you explicitly define the return type of the function. You can pass down a generic type argument to Promise as well so you don't accidentally return a different type of data and that might cause bugs to your code.