[Error: Unknown error, status code 404]​​​​​



  • Hi,

    I got 404 error when trying to render a sample report.

    My code for inline sample:
    const client = require('jsreport-client')('http://localhost:5488/api/report');
    client.render({
    template: {
    content: "hello {{:someText}}", recipe: "html",
    engine: "jsrender"
    },
    data: { someText: "world!!" }
    }, function (err, response) {
    err
    response.body(function (body) {
    //prints hello world!!
    console.log(body.toString());
    });
    });

    I tried with the Invoice template but It emitted the same error.
    const client = require('jsreport-client')('http://localhost:5488/api/report');

    client.render(
    {
    template: { shortid: "rkJTnK2ce" },
    engine: "handlebars",
    recipe: 'phantom-pdf',
    data: { to: "Pavel Sladek", from: "Ban Blaha", price: "800" }
    },
    function (err, resp) {
    err;
    console.log(err);
    console.log(resp);
    // response.body(function(body) {
    // //prints hello world!!
    // console.log(body.toString());
    // });
    });

    ​​​​​{ [Error: Unknown error, status code 404]​​​​​
    ​​​​​ response: ​​​​​
    ​​​​​ IncomingMessage { _readableState: ​​​​​
    ​​​​​ ReadableState { objectMode: false,​​​​​
    ​​​​​ highWaterMark: 16384,​​​​​
    ​​​​​ buffer: [Object],​​​​​
    ​​​​​ length: 0,​​​​​
    ​​​​​ pipes: [Object],​​​​​
    ​​​​​ pipesCount: 1,​​​​​
    ​​​​​ flowing: true,​​​​​
    ​​​​​ ended: true,​​​​​
    ​​​​​ endEmitted: true,​​​​​
    ​​​​​ reading: false,​​​​​
    ​​​​​ ... },​​​​​
    ​​​​​ readable: false,​​​​​
    ​​​​​ domain: null,​​​​​
    ​​​​​ _events: ​​​​​
    ​​​​​ { end: [Object],​​​​​
    ​​​​​ close: [Object],​​​​​
    ​​​​​ error: [Object],​​​​​
    ​​​​​ data: [Object] },​​​​​
    ​​​​​ _eventsCount: 4,​​​​​
    ​​​​​ _maxListeners: undefined,​​​​​
    ​​​​​ socket: ​​​​​
    ​​​​​ Socket { connecting: false,​​​​​
    ​​​​​ _hadError: false,​​​​​
    ​​​​​ _handle: null,​​​​​
    ​​​​​ _parent: null,​​​​​
    ​​​​​ _host: 'localhost',​​​​​
    ​​​​​ _readableState: [Object],​​​​​
    ​​​​​ readable: false,​​​​​
    ​​​​​ domain: null,​​​​​
    ​​​​​ _events: [Object],​​​​​
    ​​​​​ _eventsCount: 8,​​​​​
    ​​​​​ ... },​​​​​
    ​​​​​ connection: ​​​​​
    ​​​​​ Socket { connecting: false,​​​​​
    ​​​​​ _hadError: false,​​​​​
    ​​​​​ _handle: null,​​​​​
    ​​​​​ _parent: null,​​​​​
    ​​​​​ _host: 'localhost',​​​​​
    ​​​​​ _readableState: [Object],​​​​​
    ​​​​​ readable: false,​​​​​
    ​​​​​ domain: null,​​​​​
    ​​​​​ _events: [Object],​​​​​
    ​​​​​ _eventsCount: 8,​​​​​
    ​​​​​ ... },​​​​​
    ​​​​​ httpVersionMajor: 1,​​​​​
    ​​​​​ httpVersionMinor: 1,​​​​​
    ​​​​​ ... } }​​​​​

    Does anyone know why?

    Thanks.


  • administrators

    the url passed should be the base url where your jsreport instance is running

    const client = require('jsreport-client')('http://localhost:5488/');
    


  • I've made it now more clear in docs - https://jsreport.net/learn/nodejs-client



  • Thanks a lot. It works now.


Log in to reply
 

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