Skip to content
Advertisement

Uncaught TypeError: Cannot read properties of undefined (reading ‘companyName’) JS Objects

i have a problem about when i trying mapping my data. I want a reach company name in supplier in products. How can i fix it?

JavaScript

this is error message error

this is data:

https://northwind.vercel.app/api/products

edit:

@Tim Roberts found the solution. Only some elements have a supplier so other one’s dont have. i took the error message when i try map. I understand now.

Advertisement

Answer

I think the error occurs because in some data from the api, the supplier prop doesn’t exist.

Your code

JavaScript

Possible Solution

JavaScript
Advertisement