Encountering an Uncaught TypeError message: Cannot read properties of undefined (reading '_ref').
While attempting to utilize code for displaying API content on a webpage, what might be causing this issue and how can it be resolved to successfully show the contents on the page?
const displayItems = (category: number) => {
return products.filter((item) => item.category._ref === categories[category]._id).map((item) => <Item item={item} key={item._id}/>);
};