Express 为什么flatmap操作符没有按我理解的那样工作?
Express 为什么flatmap操作符没有按我理解的那样工作?,express,rxjs,reactive-programming,observable,flatmap,Express,Rxjs,Reactive Programming,Observable,Flatmap,fetch(url)返回一个承诺,我正在使用flatmap将其转换为可观察。为什么这不起作用 Rx.Observable .from(imgSrc) .map(url => fetch(url)) .flatmap( res => R.Observable.fromPromise(res)) .subscribe( function(res) { console.log(res);
fetch(url)
返回一个承诺,我正在使用flatmap将其转换为可观察。为什么这不起作用
Rx.Observable
.from(imgSrc)
.map(url => fetch(url))
.flatmap( res => R.Observable.fromPromise(res))
.subscribe(
function(res) {
console.log(res);
},
function(err){
console.log("Errorororrororororor:"+JSON.stringify(err));
response.status(500).send(
{
"error":err
});
},
function(){
console.log("completed promise!!")
response.status(200).send(
{"data": [{
"id": "testing id",
"url": "https://test.com/1.jpg"
}]
});
}
);
它是如何不起作用的?你确定这不是因为你有
R.Observable.fromPromise
而不是Rx
,在开始时只使用R
。。好的,我明白了。。你说得对..我对flatmap回调的输入感到困惑。。将删除此答案。我猜OP的问题是输入错误。而且操作是flatMap
而不是flatMap
非常感谢。我讨厌JS就是因为这个打字错误和平面图。。。grr。。。。。。。。。。。