Angular 2 RC5 http错误处理
我是Angular 2的新手,在Angular 2项目中,我创建了返回json数据的API调用服务Angular 2 RC5 http错误处理,http,angular,typescript,webpack,zone,Http,Angular,Typescript,Webpack,Zone,我是Angular 2的新手,在Angular 2项目中,我创建了返回json数据的API调用服务 this._http.post(this.url, body, options) .map(response => response.json()) .catch(this.handleError); 假设此服务返回401HTTP响应未经授权,我尝试获取状态错误,因此我可以重定向到登录页面
this._http.post(this.url, body, options)
.map(response => response.json())
.catch(this.handleError);
假设此服务返回401HTTP响应未经授权,我尝试获取状态错误,因此我可以重定向到登录页面并显示错误消息
.subscribe(
login => this.login=login,
error => this.errorMessage = <any>error);
}
有什么建议吗
多谢各位
this.invoke = function () {
try {
return zone.runTask(self, this, arguments);
}
finally {
drainMicroTaskQueue();
}
};
}