我正在尝试map
从服务呼叫中获取但出现错误。看着subscribe没有在角度2中定义?它说,要订阅,我们需要从运营商内部返回。我也有return语句。
这是我的代码:
checkLogin(): Observable<boolean> {
return this.service.getData()
.map(
response => {
this.data = response;
this.checkservice = true;
return true;
},
error => {
// debugger;
this.router.navigate(['newpage']);
console.log(error);
return false;
}
)
.catch(e => {
return e;
});
}
错误日志:
TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable
You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
但是这发生在我的服务器运行时,我在分支之间切换。我需要做的就是重启服务器,然后服务器消失了。