Rendering Template html preview inside element div from nodejs



  • Hello,

    actually i'm trying to render a template from my nodejs app using get request.

    My question is, can i render the template inside a specific element of html instead of showing everything in a new tab?

    I have 2 files, one has the jsreport-client render and the other one has the html structure

    Nodejs request code:

    app.get('/report', (req, res, next) => {

    client.render({template: { name:"main_office"}}
    ).then((response) => response.pipe(res))
    .catch(next)
    console.log(res)
    })

    i would like to render this template inside a div, for example, but i couldn't get it to work because i'm not doing rendering inside <script> tag.

    Any help?

    Thank yoy


  • administrators

    hi! i think you have two options:

    • use the browser client, it has methods to either put the report response directly to html element (.render) or to fire an http request from the browser and give your client-side code the response data for you to handle it in the way you want (.renderAsync), you can add it to html element from there.
    • do an http request from your browser and call your server /report route, from there handle the response and attach it to custom html element, it is the same as renderAsync but everything handled by you

Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.