【发布时间】:2021-06-02 00:20:06
【问题描述】:
我正在尝试使用一种方法,该方法使用其 ID 号为我提供用户信息
组件.ts
identificacion:any = this.route.snapshot.paramMap.get('identificacion');
constructor(private route: ActivatedRoute, private dataService: DataService) {
}
async ngOnInit() {
await this.dataService.getParticipeByIdentificacion(this.identificacion).subscribe(resonse => console.log(resonse))
}
服务调用:
getParticipeByIdentificacion(id) {
this.tokenvalido();
const token = this.getToken();
return this.http.get(`${this.apiUrl}/participe/identificacion/${id}`);
}
来自 api 的响应:
{
"result": {
"actividadEconomica": null,
"genero": "Masculino",
"estadoCivil": "SOLTERO",
"contratos": [],
"contactos": [],
"direcciones": [],
"referenciasPersonales": [],
"referenciasBancarias": [],
"idParticipe": 195,
"idTipoIdentificacion": 1,
"tipoIdentificacion": null,
"identificacion": null,
"nombres": "WILMER JAVIER",
"apellidos": "DECIMAVILLA ESPINOZA",
"razonSocial": "WILMER JAVIER DECIMAVILLA ESPINOZA",
"fechaRegistro": "2021-02-08T19:57:30.277",
"fechaModificacion": "2021-05-12T11:39:31.413",
"usuarioRegistro": "SYSTEM",
"usuarioModificacion": "",
"estado": "Aprobado",
"fechaNacimiento": "",
"lugarNacimiento": "N/A",
"idNacionalidad": 1,
"fechaExpedicionCedula": "0001-01-01T00:00:00",
"correo1": null,
"correo2": null,
"telefono1": null,
"telefono2": null,
"celular": null,
"idGenero": 1,
"idEstadoCivil": 1,
"idNivelEstudios": 3,
"idNivelIngresos": 2,
"idProfesion": 1,
"idGrado": 102,
"identificacionConyuge": null,
"conyuge": null,
"idTipoVivienda": 1,
"tiempoResidencia": 1,
"photoUrl": null,
"codigoUniformado": null,
"fechaIngreso": "2010-10-21T00:00:00",
"aporteAdicional": 0,
"observaciones": null
},
"error": null,
"message": "El servidor respondio con el codigo de estado: 200 OK",
"statusCode": "OK",
"success": true
}
我得到的错误:
错误类型错误:您在预期流的位置提供了“未定义”。您可以提供 Observable、Promise、Array 或 Iterable。
希望你们能帮我解决这个问题:)
【问题讨论】:
-
我怀疑该错误与您发布的代码有关。此外,您不能等待可观察(或订阅)..
标签: angular