From c960b31f1782eea1724e1dbcefc8e4ad24a4fcf4 Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Fri, 14 Aug 2020 19:36:51 +0530 Subject: [PATCH] Fix Bing API search issue --- src/services/FilesSearchService.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/services/FilesSearchService.ts b/src/services/FilesSearchService.ts index 98468b413..3bf6e7700 100644 --- a/src/services/FilesSearchService.ts +++ b/src/services/FilesSearchService.ts @@ -144,12 +144,9 @@ export class FilesSearchService { } // Submit the request - const apiUrl: string = `https://api.cognitive.microsoft.com/bing/v7.0/images/search?traffictype=Internal_monitor&q=${encodeURIComponent(query)}&count=${maxResults}&aspect=${aspect}&maxFileSize=${maxFileSize}&mkt=en-US&size=${size}&license=${license}`; - const headers = new Headers({ - 'Ocp-Apim-Subscription-Key': this.bingAPIKey - }); - const searchDataResponse: any = await this.context.httpClient.get(apiUrl, SPHttpClient.configurations.v1, { - headers: headers, + const apiUrl: string = `https://www.bingapis.com/api/v7/images/search?appid=${this.bingAPIKey}&traffictype=Internal_monitor&q=${encodeURIComponent(query)}&count=${maxResults}&aspect=${aspect}&maxFileSize=${maxFileSize}&size=${size}&mkt=en-US&license=${license}`; + + const searchDataResponse: any = await this.context.httpClient.get(apiUrl, SPHttpClient.configurations.v1, { method: 'GET', mode: 'cors' });