I have a JSON that contains multiple data which I need to edit, through typescript I found that I can modify it using map
his.items = this.items.map((item: string) =>
Now inside the item I have a route item.better_featured_image that contains an object but sometimes contains only null, I want to modify it and add the missing route. but apparently I am in an error since the path to be null is no longer an object
this.items = this.items.map((item: string) => {
if(item.better_featured_image == null){
let item.better_featured_image = {};
item.better_featured_image.media_details.sizes.thumbnail.source_url = 'logo-web-color.png';
}
return item;
});
json complete here link
My idea is to create the missing route in the object that contains null