Trying to pass request parameters using model structure in typescript. It works fine for non-nested objects, but encountering issues with nested arrays as shown below:
export class exampleModel{
products: [
{
name: string,
address:string,
product_sizes: [
{
quntity: number,
price: number,
id: [
number
]
}
]
}
]
}
After creating the model, initializing it as follows:
productRequestObject : exampleModel = <exampleModel>{}
Attempts to assign values result in an error:
this.productRequestObject.products[0].name = sessionStorage.getItem('name')
Error message received:
Cannot read property '0' of undefined
Any suggestions or insights on what might be missing are greatly appreciated!