调用接口的时候,报错,信息如下:
ERROR TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
at subscribeTo (subscribeTo.js:41)
at subscribeToResult (subscribeToResult.js:11)
at CatchSubscriber.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:43)
原因:
我使用了http拦截器,处理的时候,少了东西。eg:
if (!!error && error.status === 401) {
return;
}
直接return了,其实接口需要一个返回,直接return不行的,所以报错;加上一个返回值就ok了。eg:
return of(1); // 最终接口取不到值,但是不报错了。