Understanding the Format of JSON Array in LocalStorage
Greetings, I am currently working on an Ionic app and I am relatively new to Ionic and Typescript.
In the image provided below, you can see that I am retrieving my data from an API in a json array format.
Within the TypeScript file, I have written the following code:
` public categoryDetails:any;
const datacat = JSON.parse(localStorage.getItem('categoryData')); this.categoryDetails = datacat.categoryData;`
When I include this line in my HTML file:
<h1 class="business-top">Business of the category {{categoryDetails.name}}</h1>
I encounter an error message stating "TypeError: Cannot read property 'name' of undefined."
I understand that I am not reading the attribute "name" correctly. What is the correct approach to resolve this issue?
Furthermore, how can I display businesses associated with the specific term_id of the category?