angular - 获取特定的 Observable 值
问题描述
所以目前我正在尝试从此响应正文中检索monthlyFee 值。
解决方案
在getCurrentPlan
函数中设置响应类型:
.subscribe((currentPlanResponse: CurrentPlan[]) => {
let currentPlan: CurrentPlan[] = currentPlanResponse;
console.log('monthlyFee: ',
currentPlan[0].planGroupMap.sharePlans.plans[0].monthlyFee);
});
请记住,您正在获取一个数组(或嵌套数组),因此这取决于您要对最终结果做什么,但上面显示了谁获取嵌套值。
检查我根据您的代码制作的这个 StackBlitz:https ://stackblitz.com/edit/rxjs-aesbq2
我评论了您的代码的某些部分,以便不创建整个服务和 http 请求,但正如您所说,这不是您的实际问题。
推荐阅读
- r - 如何使用 R 池将参数传递给新数据框以进行 SQL UPDATE
- jquery - Mesonet API JSON 对 html 表的响应
- c# - 如何在列表中选择某些属性
- json - AWS DynamoDB 向现有表添加值的问题
- python - 计算数据框熊猫中的重复单词
- android - 按特定值对用户进行排序
- python - 使 Matplotlib 注释可读/不那么密集
- swiftui - GoogleSignIn - 未找到框架 AppAuth SwiftUI
- javascript - fs.append 到已经存在的 JSON 行
- javascript - 根据与坐标的距离,生成分数。(距离越小=>得分越高)