我想通过回调函数格式化我的API响应,并在angular订阅中获取数据
我用过mergemap,但没有用。
this.http.get('https://some.com/questions.xml', {headers, responseType: 'text'})
.mergeMap(
res => xml2js.parseString(
res,
{ explicitArray: false },
(error, result) => {
if (error) {
throw new Error(error);
} else {
console.log(result);
return result;
}
}
)
).subscribe(
data => { console.log("response", data); },
error => { console.log(error); }
);
我想在subscribe中获得响应JSON,但我得到了TypeError:您提供了一个需要流的无效对象。您可以提供Observable、Promise、Array或Iterable。
转载请注明出处:http://www.fulida88.com/article/20230526/1407057.html