This example illustrates loading of the report that uses json database from some web-server and accessible only by suppliing custom HTTP header. That report is rendered and result is stored to the mdc-file.

Installation and running
Use npm to install requred modules:
$ npm install
Run Sample:
$ npm start

Step by step
Stimulsoft Reports.JS module loading:
const Stimulsoft = require('stimulsoft-reports-js');
Creating new report:
const report = new Stimulsoft.Report.StiReport();
Add onBeginProcessData event handler and set necessary headers:
report.onBeginProcessData = function (args) {
    if (
        args.database === "JSON" && 
        args.command === "GetData" && 
        args.pathData && args.pathData.endsWith("/ProtectedDemo.json")
    ) {
        // Add custom header to pass through server protection
        args.headers.push({key: "X-Auth-Token", value: "*YOUR TOKEN*"});
    }
};
Loading sample report template:
report.loadFile("SimpleListWithProtectedJson.mrt");
Renreding report and saving rendered report to mdc-file:
report.renderAsync(function () {

    // Saving rendered report to file
    report.saveDocumentFile("SimpleListWithProtectedJson.mdc");
});

Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:

Supply Custom Headers for JSON Database

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.