How spawn curl request in function beforeRender ?

  • Hi, how i can do spawn curl request from cmd.exe in function beforeRender ?
    For example

      const { spawn } = require('child_process');
       let args = [
           ...some args
        const curl = spawn('curl',
            args, {
                shell: true
       curl.on('close', (code) => {
            console.log(`child process exited with code ${code}`);
        curl.on('data', (data) => {

    Thank you in advance

  • Isn't it better to use a nodejs module for making http requests? Like this

    //load some data from the remote API
    function beforeRender(req, res, done) {
        }, function(err, res, body){
   = Object.assign({},, body);

  • i use curl, because i need do request to service, where use kerberos authentication. And i think its possible to do only if use curl with flag --negotiate. Thank you.

  • Maybe I am wrong but I doubt it won't with a module.

    However here is the code for curl you can expand

    const spawn  = require('child_process').spawn
    function beforeRender(req, res, done) {
        const curl = spawn('curl', [''], { shell: true })    
        curl.stdout.on('data', (data) => {
            console.log(`stdout: ${data}`)
        curl.stderr.on('data', (data) => {
            console.error(`stderr: ${data}`)
        curl.on('close', (code) => {       

  • Thanks a lot )

Log in to reply

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