sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

AadHttpClient calls not working in IE 10, IE 11

Open srinivasnarula opened this issue 7 years ago • 7 comments

Category

  • [x] Question
  • [ ] Typo
  • [ ] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

I'm using SPFx 1.7 version and should fetch data from azure ad authenticated web api using AadHttpClient and display in table format using Chrome and IE versions.

I followed every step mentioned in the below link in the context of webapp. https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aadhttpclient-enterpriseapi

Observed Behavior

SPFx webpart is able to fetch data properly in Chrome, but NOT in IE 11, IE 10 version.

I've attached one screen shot of the console log, which has error in sp-http-adal.js file. ie-workbench issue

ie-workbench issue -1

Steps to Reproduce

Here is the code which I'm using to get the data

EndPoint : https://test.azurewebsites.net/api/v1/reports/getdata

  public getServerData(APIENDPOINT: string, ErrorMessage: string): Promise<ITest[]> {
    return new Promise<ITest[]>((resolve, reject) => {
      console.log('getServerData.......');
      this.aadHttpClientFactory
        .getClient(TEST_RESOURCE_ENDPOINT_URI)
        .then((aadHttpclient: AadHttpClient) => {
          const endpoint: string = `${TEST_ENDPOINT_URI + APIENDPOINT}`;
          console.log('endpoint...->'+endpoint);
          aadHttpclient.get(endpoint, AadHttpClient.configurations.v1,)
            .then((rawresponse: HttpClientResponse) => {
              if (rawresponse.status === 200) {
                console.table(rawresponse);
                return rawresponse.json();
              } else {
                throw new Error(`${ErrorMessage}`);
              }
            })
            .then((jsonResponse: ITest[]) => {
              console.log(jsonResponse);
              resolve(jsonResponse);
            })
            .catch((error) => {
              reject(error);
            });
        });
    });
  }

Please help me, if I need to alter my code or settings for the code to work with IE .

srinivasnarula avatar Mar 08 '19 15:03 srinivasnarula

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Mar 08 '19 15:03 msft-github-bot

I have the same problem.

Please if anyone knows how to solve it please comment soon, thanks

SPFxDeveloper avatar Mar 08 '19 17:03 SPFxDeveloper

@SPFxDeveloper , @andrewconnell , @wobba

The issue is with console.table function. It was not allowing to process the success request as it is NOT supported in IE browsers. Thanks alot for your help.

 public getServerData(APIENDPOINT: string, ErrorMessage: string): Promise<ITest[]> {
    return new Promise<ITest[]>((resolve, reject) => {
      console.log('getServerData.......');
      this.aadHttpClientFactory
        .getClient(TEST_RESOURCE_ENDPOINT_URI)
        .then((aadHttpclient: AadHttpClient) => {
          const endpoint: string = `${TEST_ENDPOINT_URI + APIENDPOINT}`;
          console.log('endpoint...->'+endpoint);
          aadHttpclient.get(endpoint, AadHttpClient.configurations.v1,)
            .then((rawresponse: HttpClientResponse) => {
              if (rawresponse.status === 200) {
               //console.table(rawresponse); //console.table function doesn't support IE browsers.
                return rawresponse.json();
              } else {
                throw new Error(`${ErrorMessage}`);
              }
            })
            .then((jsonResponse: ITest[]) => {
              console.log(jsonResponse);
              resolve(jsonResponse);
            })
            .catch((error) => {
              reject(error);
            });
        });
    });
  }

As the issue is fixed. Closing the request.

srinivasnarula avatar Mar 13 '19 16:03 srinivasnarula

@narulasrinivas console calls is basically a no-no with IE11 and should be avoided. Better to use SPFx or PnP logging.

wobba avatar Mar 14 '19 08:03 wobba

@wobba well... better to avoid IE11 ;)

andrewconnell avatar Mar 14 '19 10:03 andrewconnell

@andrewconnell always - but unfortunately not something one can control usually :(

wobba avatar Mar 14 '19 13:03 wobba

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 25 '20 00:01 msft-github-bot