【发布时间】:2019-12-09 21:46:07
【问题描述】:
ObtenerClientes(cantidad: number): Observable<Array<Cliente>> {
const urlCliente = `${this.url}/?results=${cantidad}`;
const lstClientes: Array<Cliente> = [];
return this.http.get<any>(urlCliente).pipe(
map(clientes => {
(clientes.results as Array<any>).forEach((registro: any ) => {
lstClientes.push({
id: registro.CustomerID,
nombre: registro.ContactName,
companyName: registro.CompanyName
});
});
return lstClientes;
})
);
}
}
拜托,我需要一些帮助!
【问题讨论】:
-
这意味着它不是一个数组,所以它没有 forEach 方法。
clientes.results是undefined,因此您的查询不会返回任何内容。