Supply Custom Headers for JSON Database
Наши примеры проектов и шаблоны отчётов помогут Вам разобраться в основах работы с нашими продуктами.When a JSON data source is served by a protected backend, you can attach custom HTTP headers to each data request.
Preparing the data. Read or create the data source, register it in the report dictionary, synchronize the schema, and render with the supplied records.
The
На скриншоте ниже Вы можете увидеть результат выполнения данного кода:

Preparing the data. Read or create the data source, register it in the report dictionary, synchronize the schema, and render with the supplied records.
@Component({
selector: "supply-custom-headers-for-json-database",
imports: [Viewer],
template: `<sti-viewer [report]="report" [options]="viewerOptions"></sti-viewer>`
})
export class SupplyCustomHeadersForJsonDatabase {
report: Stimulsoft.Report.StiReport;
viewerOptions: Stimulsoft.Viewer.StiViewerOptions;
constructor() {
this.report = new Stimulsoft.Report.StiReport();
this.report.loadFile("Reports/MasterDetail.mrt");
this.report.onBeginProcessData = function (args) {
if (args.database === "JSON" && args.command === "GetData") {
// Add custom header to pass through backend server protection
args.headers.push({ key: "X-Auth-Token", value: "*YOUR TOKEN*" });
}
};
this.viewerOptions = new Stimulsoft.Viewer.StiViewerOptions();
this.viewerOptions.appearance.fullScreenMode = true;
}
}The
onBeginProcessData event fires before every data request; pushing an entry onto args.headers (here an X-Auth-Token) lets the call pass through server-side protection.На скриншоте ниже Вы можете увидеть результат выполнения данного кода:
