I created a list of pdf paths and tried to merge them in one file, but I'm getting Unhandled promise Error: already ended
this is my code, I tried also to await while adding to pdf but didn't like it Is there any way to handle this error?
listOFPdf.push(docPath.filepath);//list of pdf paths
const merger = new PDFMerger();
(async()=>{
listOFPdf.forEach(file=> { //loop through paths and merge them
const mergedPdf = await merger.save(file); // save the path
})
}) ();// calling the function