T
T
tyoma_koder2021-10-17 18:33:58
Angular
tyoma_koder, 2021-10-17 18:33:58

How to get angulaR asynchronous variable?

There is a json file, I get its contents via fetch and display the length of this array, but when I get the length, I get the error "Cannot read properties of undefined" in the console, although the list of elements and the length are still displayed, how to get rid of the error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lssssssssssl, 2021-10-17
@tyoma_koder

Add a question if in the template, for example: {{users?.length}}
Or assign to your default array []: public users = []
That's why it's better not to disable it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question