Javascript 角度rxjs中的转换API响应

Javascript 角度rxjs中的转换API响应,javascript,angular,api,rxjs,Javascript,Angular,Api,Rxjs,嗨,我收到API的回复: { "records":[ { "id":1, "motivazione":"", "autorizzazione":false, } ] } 我如何将其转换为这样: [ { "id":1, "moti

嗨,我收到API的回复:

{
   "records":[
      {
         "id":1,
         "motivazione":"",
         "autorizzazione":false,

      }
   ]
}
我如何将其转换为这样:

[
      {
         "id":1,
         "motivazione":"",
         "autorizzazione":false,

      },
   ]
谢谢


约瑟夫这个问题不清楚。如果您只需要获取属性
记录的内容
,则可以通过管道将
pull
操作符传送到HTTP请求

从“rxjs/operators”导入{pull};
公共函数():可观察{
返回此.http.get(url).pipe(
弹拨(“记录”)
);
}
或者,您也可以使用
map
操作符

从'rxjs/operators'导入{map};
公共函数():可观察{
返回此.http.get(url).pipe(
映射((res:any)=>res['records'])
);
}

这将只从响应对象返回record属性。

这与Angular或RXjs之间有什么关系?此外,您正在开发一个角度应用程序,其中包含了可观测数据和所有数据,但您不知道如何从数组或对象中提取元素?友好的建议,也许您应该先学习一些“Javascript 101”教程,然后再处理:)您不能从订阅的回调中返回值。@MichaelD Yes!!修好了。
You can use the map operator in rxjs to transform your data. More precisely if you only want the records property from your response object you can do that as following: 

import { map } from 'rxjs/operators';

transformData(){
     this.http.get(url).pipe(map((target: any) => target.records)).subscribe((data) => {
   console.log(data);
    })}