Skip to content
Advertisement

Get an array of items from an object- typescript

I have an object with the below structure:

JavaScript

the order is of type Order[] and users of type UserData[]

JavaScript

Whenever I try to get the list of users per order :

let users = this.Order.users

it says that: users don’t exist on type Order[], can anyone explain for me why.

Advertisement

Answer

Order is an array of objects, you need to get the first element like Order[0] then access .users

JavaScript

A good refresher might help here; How can I access and process nested objects, arrays or JSON?

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement