在服务中,有以下代码:
getUser(id){
return this.http.get('http:..../' + id)
.map(res => res.json());
}
在组件中:
this.myService.getUser(this.id).subscribe((customer) => {
console.log(customer);
this.customer = customer,
(err) => console.log(err)
});
当"客户"存在时,没问题,我会得到关于客户的所有信息.
当id不存在时,web api返回"BadRequest"并显示一条消息.我怎样才能得到这个信息?情况如何?
谢谢,