问题描述
我想展示一个烤面包,该烤面包的文本取决于HTTP响应的状态码。 服务中的代码:-
private options = {
headers: new HttpHeaders()
.set("Content-Type","application/json")
.set("x-app-id",this.appId)
.set("x-app-key",this.appKey)
.set("observe","response")
};
constructor(private http: HttpClient) {}
search(query: string): Observable<{}> {
return this.http.post(this.url,{query: query},this.options)
}
这就是我在前端所做的:-
search() {
this.showcard = false;
this.isLoading = true;
this.nutrix.search(this.searchValue).subscribe((res) => {
if(res){
this.isLoading = false;
this.showcard = true;
this.queryResult = res["foods"][0];
this.imageUrl = this.queryResult['photo']['thumb']
}
console.log(this.queryResult);
},(error) => {
console.log(error);
this.isLoading = false;
});
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)