I want to implement Bing Images API in my Angular app. For now I will do it client side. But I get a 404 answer when making a GET request.
@Injectable()
export class BingService {
private endpoint =
"https://api.bing.microsoft.com/bing/v7.0/images/search";
private token = "9dc015a3a15c45abb05f88bcea641c2d";
constructor(private httpClient: HttpClient) {}
getImage(term: string) {
const httpParams = new HttpParams({
fromObject: {
q: term,
count: "1"
}
});
const httpHeaders = new HttpHeaders({
"Ocp-Apim-Subscription-Key": this.token
});
httpHeaders.set("Ocp-Apim-Subscription-Key", this.token);
return this.httpClient.get(this.endpoint, {
params: httpParams,
headers: httpHeaders
});
}
}
Here is a stackblitz with the issue