I need to return a value from within a function and that function pdf.create().tofile() always returns undefined. Now if I explicitly try to return a variable by making it global, I am not able to do it in typescript. Can someone help? Please refer as below:
var serviceS3Result: any;
await pdf
.create(stocksReport({}))
.toFile(`./dist/test.pdf`, async (err, res) => {
if (err) console.log(err);
console.log('hi from inside', res);
serviceS3Result = await this.s3Service.uploadFileFromSystem(
`test`,
fs.readFileSync(`./dist/test.pdf`),
`test.pdf`
);
fs.unlinkSync(`./dist/test.pdf`);
});
return serviceS3Result;
this returns undefined, any idea why?
pdf? At least from the snippet, it looks like the operationtoFileaccepts callback...