我正在将我的Ionic3应用程序移植到Ionic5中,目前正在添加我的http请求。在Ionic3中,我使用了angular/http,但它似乎是deprecated。这是我对可观察性的代码:
this._http.get(requestURL)
.map((result: Response) => {
return this.run(result.json())
});现在,我如何用Ionic5来完成同样的实现呢?
Rx.Observable.fromPromise(fetch(url));?上面的方法似乎不起作用。fromPromise does not exist on Rx.Observeable。
发布于 2020-06-05 13:01:25
如果使用的是RxJS 6,则应改用from运算符,该运算符会将promise转换为observable
const request = fetch(url);
from(request).pipe(
switchMap(response => response.json()),
... carry out other operations here.
)https://stackoverflow.com/questions/62208337
复制相似问题