Bing 图片搜索 Angular
Bing images search in Angular
我想在我的 Angular 应用中实现 Bing 图片 API。现在我会做客户端。但是我在发出 GET
请求时得到了 404 答复。
@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
});
}
}
这是一个stackblitz问题
APIurl无bing
:
private endpoint = "https://api.bing.microsoft.com/v7.0/images/search";
工作stack
我想在我的 Angular 应用中实现 Bing 图片 API。现在我会做客户端。但是我在发出 GET
请求时得到了 404 答复。
@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
});
}
}
这是一个stackblitz问题
APIurl无bing
:
private endpoint = "https://api.bing.microsoft.com/v7.0/images/search";
工作stack