Hi,
How can generate a pdf or excel using shortid
I have tried this code but doesn't work.
static async BIReporting(req:Request, res:Response){
console.log('Quering JS Reports');
try {
const data = {
template: { shortid: 'RHdf7jP' },
data: {test: 'test'},
options: {'Content-Disposition': `attachment; filename=test.pdf`}
};
const options = {
method: 'POST',
headers: {
'Authorization': 'Basic ' + base64("admin:password"),
'Content-Type': 'application/json',
},
uri: 'https://villageco.jsreportonline.net/api/report',
json: data
};
request(options).pipe(res);
} catch(err) {
console.log(`Error creating pdf ${err} `)
return res.sendStatus(500)
}
// async function render () {
// const res = await client.render({
// template: {
// 'shortid':'RHdf7jP',
// },
// data: { someText: 'world!!' }
// })
// const bodyBuffer = await res.body()
// console.log(bodyBuffer.toString())
// }
// render().catch(console.error)
}