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"
}]
});
}
);