【发布时间】:2018-07-09 02:27:34
【问题描述】:
请您指导我正确的方向吗?
我正在尝试从旧的 Http REST 服务中提取记录,重组数据,然后将其发布到 firebase。
我不确定这是完全错误的方法还是我完全误解了 observable 的方法。您的指导将不胜感激。如何将此新列表发送到另一个 DataService 函数:exportToFirebase(new_listing)?
onServiceCall() {
this.httpDataService.getData().subscribe((itemData) => {
this.itemDataJSON = itemData;
if (this.itemDataJSON) {
this.itemDataJSON.forEach(function(value) {
let new_listing = new Listing(value.id, value.name, value.category);
//console.log(new_listing);
//How to send this new listing to another firebaseDataService function exportToFirebase(new_listing);
});
}
});
}
【问题讨论】:
-
您不能“发送”数据,但另一方面您可以拉取数据。因此,不要从
onServiceCall()发送它,而是在您的DataService上调用this.httpDataService.getData(),然后使用.switchMap或.map对结果做任何你想做的事情。 -
exportToFirebase 的函数签名是什么
-
exportToFirebase返回什么?
标签: http rxjs httpclient angular6 subscribe