angular - 如何迭代从可观察的响应返回的数据
问题描述
大家好,我是 JavaScript 新手,开始学习 Angular。这是 Spring Boot 应用程序返回的应用程序的响应。我想知道如何使用 ForEach 循环来交互这个 UserCred 对象。
Response from the Server
UserCred {username: "Prawin", password: "password"}
password: "password"
username: "Prawin"
__proto__:
constructor: class UserCred
arguments: (...)
caller: (...)
length: 2
name: "UserCred"
prototype: {constructor: ƒ}
__proto__: ƒ ()
[[FunctionLocation]]: user-registration.service.ts:6
[[Scopes]]: Scopes[2]
__proto__:
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
propertyIsEnumerable: ƒ propertyIsEnumerable()
toLocaleString: ƒ toLocaleString()
toString: ƒ ()
valueOf: ƒ valueOf()
__defineGetter__: ƒ __defineGetter__()
__defineSetter__: ƒ __defineSetter__()
__lookupGetter__: ƒ __lookupGetter__()
__lookupSetter__: ƒ __lookupSetter__()
get __proto__: ƒ __proto__()
返回响应的一段代码。
handleLogin(){
console.log("inside Login");
console.log(this.username);
console.log(this.password);
this.userRegistartionService.postUserCredientials(this.username, this.password)
.subscribe(data => {
console.log(typeof data);
this.loginService.aunthenticate(this.username);
this.router.navigate(["application/manage"]);
});
}
我需要从名为“data”的响应对象中获取数据
我想具体获取用户名和密码。因为它是一个响应对象,所以我正在努力使用 ForEach 循环获取数据。
解决方案
推荐阅读
- laravel - 在 Eloquent 中默认忽略具有特定值的列
- java - Java - 修改复制的数组也会影响原始数组
- java - 如何在java中垂直循环遍历二维数组
- python-3.x - Folium choropleth 根本不给邮政编码区域着色
- java - 特殊字符检查,如果语句不起作用。爪哇
- django - Django 检索 CRSF 令牌
- swift - 更新 ObservableObject 值会关闭视图
- google-api - google 的 DCM api 中的什么会给我返回字段的数据类型?
- javascript - React-Bootstrap 不适用于组件
- rust - 为什么在字节数组上使用 AsciiString::from_ascii 时出现错误“索引处的字节不是 ASCII”?