I'm embedding powerbi reports on my page via powerbi js embedded (ajax) and I'm having problems with getting pages from powerbi reports.
I've already tried the .load method and report.getPages() throws this error:
ERROR Error: Uncaught (in promise): Object: {"data":"","status":401,"activityId":"xxx","requestId":"yyy","responseRequestId":null,"pendingRequestCount":0}
My JS is like this:
tab == null ? 0 : tab;
// call load() instead of embed() to load the report while delaying the rendering process
var report = powerbi.load(embedContainer, config);
// when loaded event occurs, set current page then call render()
report.on("loaded", function () {
console.log("loaded event executing");
// call to get Pages collection
report.getPages().then(
function (pages) {
// inspect pages in browser console
console.log(pages);
// display specific page in report
var startPage = pages[1]; // this selects the second page
config.pageName = startPage.name;
// Call report.render() to display report
report.render(config);
});
});
I expect the load of the report before the renderization of the page, and not after.