AadHttpClient calls not working in IE 10, IE 11
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.
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 .
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
I have the same problem.
Please if anyone knows how to solve it please comment soon, thanks
@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.
@narulasrinivas console calls is basically a no-no with IE11 and should be avoided. Better to use SPFx or PnP logging.
@wobba well... better to avoid IE11 ;)
@andrewconnell always - but unfortunately not something one can control usually :(
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