I have a sample, kindly have a look, if I am doing it the right way,
export const create = async ({ invitationList, testId }) => {
try {
const promises = invitationList.map(async invitationTo => {
return new Promise(async (resolve, reject) => {
const invitation = await InterviewSchedule({
invitationTo,
testId
}).save();
resolve(invitation);
});
});
Promise.all(promises).then(value => {
console.log(value);
});
} catch (error) {
throw error;
}
};
I am unable to catch the error inside the catch block.