File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { BaseComponentContext } from '@microsoft/sp-component-base' ;
2
- import { SPHttpClient } from "@microsoft/sp-http" ;
2
+ import { SPHttpClient , HttpClientResponse } from "@microsoft/sp-http" ;
3
3
import { ISearchResult , BingQuerySearchParams , IRecentFile } from "./FilesSearchService.types" ;
4
4
import { find } from "office-ui-fabric-react/lib/Utilities" ;
5
5
import { GeneralHelper } from "../common/utilities/GeneralHelper" ;
@@ -143,11 +143,14 @@ export class FilesSearchService {
143
143
}
144
144
145
145
// Submit the request
146
- 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 } ` ;
146
+ const apiUrl : string = `https://api.bing.microsoft. com/v7.0 /images/search?q=${ encodeURIComponent ( query ) } &count=${ maxResults } &aspect=${ aspect } &maxFileSize=${ maxFileSize } &size=${ size } &mkt=en-US&license=${ license } ` ;
147
147
148
- const searchDataResponse : any = await this . context . httpClient . get ( apiUrl , SPHttpClient . configurations . v1 , {
148
+ const searchDataResponse : HttpClientResponse = await this . context . httpClient . get ( apiUrl , SPHttpClient . configurations . v1 , {
149
149
method : 'GET' ,
150
- mode : 'cors'
150
+ mode : 'cors' ,
151
+ headers : {
152
+ 'Ocp-Apim-Subscription-Key' : this . bingAPIKey ,
153
+ }
151
154
} ) ;
152
155
153
156
if ( ! searchDataResponse || ! searchDataResponse . ok ) {
You can’t perform that action at this time.
0 commit comments