1
I get the error described in the title in this situation:
carregarCategorias() {
this.itemService.listarCategorias().then(lista => {
this.categorias = lista.map(categoria => ({ label: categoria.descricao, value: categoria.id }));
})
.catch(erro => this.errorHandler.handle(erro));
}
Does anyone have any tips ?
It means that
lista
is not aarray
. You can easily confirm what is doingconsole.log(typeof lista, lista)
within the Promise– Isac
The search method used in the service is this : listCategories(): Promise<Category[]> { Return this.http.get<Category[]>(this.categoriesUrl). toPromise(); } return ai is not an array ?
– ed1l50n
Thanks for the tip, really the return was a Page<> and not a list so the map does not work. Vlw
– ed1l50n