Accessing local JSReport server from local NodeJS application
-
I'm a JS amateur; please forgive me if I'm doing something wrong here. I have a local JSReport server setup using the instructions here: https://jsreport.net/on-prem. The
localhost:5488
interface works, and I'm able to generate PDFs there.
My goal is to render a report from a separate NodeJS application on the same server. I installed thejsreport
npm module in that application's folder, and then tried this script, but I getUnable to find specified template (Invoice).
const fs = require('fs').promises const jsreport = require('jsreport')({ extensions: { express: { enabled: false }, studio: { enabled: false } } }) async function main() { await jsreport.init() const result = await jsreport.render({ template: { name: 'Invoice', engine: 'handlebars', recipe: 'chrome-pdf', } }) await fs.writeFile('report.pdf', result.content) } main();
I also tried using
@jsreport/node-client
with the instructions here: https://jsreport.net/learn/nodejs-client, but I get the same error.I'm sure I'm doing something wrong, but I haven't been able to figure it out yet. Thank you for any help you can provide!
-
I figured out what I was doing wrong. The template name is actually "invoice-main".