添加retryWhen()后未调用Rxjs订阅

时间:2018-12-04 08:58:17

标签: javascript angular ionic-framework rxjs

这是给我问题的代码。

  gotoGoogle() {
    let obs = this.httpCtrl.get("https://www.google.com/", {observe : "response", responseType : "text"}).pipe(tap(() => console.log("Http GET method executed")),
    map(res => {
        console.log("The res status from GET is: ", res.status)
        console.log("The res from map is: ", res)
}),
    retryWhen(errors => {
        return errors.pipe(delayWhen(() => timer(2000)),
        tap(() => console.log("Retrying immediately..."))
        );
    })).subscribe((res : any) => {
      console.log("Status from gotoGoogle(): ", res);
    })
  }

我正在关注在线教程,代码如下所示。该代码也编译良好。当我打开控制台并运行此功能时。我注意到console.log("Status from gotoGoogle(): ", res);是“未定义”的。 但是console.log("The res status from GET is: ", res.status) and console.log("The res from map is: ", res)确实返回了状态码200和相应的答复。 “订阅”方法可能有什么问题?谢谢。

0 个答案:

没有答案
相关问题