【发布时间】:2018-04-09 11:15:44
【问题描述】:
我正在尝试在 Angular 中进行 API 调用时处理我的错误。当我无法连接到我的 API 服务并想要捕获此错误 net::ERR_CONNECTION_REFUSED 时,我收到以下消息。
我在网上搜索了一些例子,得到了这段代码。
this.http.get("http://localhost:5000/api/chatbot/connection/"+this.token).subscribe(response => {
res => this.conversation = res
},
err => {
console.log("error");
},
() => {
console.log("we're finished")
});
它到达错误部分,但它仍然返回连接错误:
我应该以不同的方式处理这个问题吗?
【问题讨论】: