async load()

in src/embed.ts [342:375]


  async load(phasedRender?: boolean): Promise<void> {
    if (!this.config.accessToken) {
      console.debug("Power BI SDK iframe is loaded but powerbi.embed is not called yet.");
      return;
    }

    if (!this.iframeLoaded) {
      console.debug("Power BI SDK is trying to post /report/load before iframe is ready.");
      return;
    }

    const path = phasedRender && this.config.type === 'report' ? this.phasedLoadPath : this.loadPath;
    const headers = {
      uid: this.config.uniqueId,
      sdkSessionId: this.service.getSdkSessionId(),
      bootstrapped: this.config.bootstrapped,
      sdkVersion: sdkConfig.default.version
    };

    const timeNow: Date = new Date();
    if (this.lastLoadRequest && getTimeDiffInMilliseconds(this.lastLoadRequest, timeNow) < 100) {
      console.debug("Power BI SDK sent more than two /report/load requests in the last 100ms interval.");
      return;
    }

    this.lastLoadRequest = timeNow;

    try {
      const response = await this.service.hpm.post<void>(path, this.config, headers, this.iframe.contentWindow);
      return response.body;
    } catch (response) {
      throw response.body;
    }
  }