Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/components/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ const Body = () => {
);

const json = await data.json();
const arrayOfCards = json?.data?.cards;
const restaurantListing = "restaurant_grid_listing";

// Optional Chaining
setListOfRestraunt(
json?.data?.cards[2]?.card?.card?.gridElements?.infoWithStyle?.restaurants
);
setFilteredRestaurant(
json?.data?.cards[2]?.card?.card?.gridElements?.infoWithStyle?.restaurants
);
for (const cardObj of arrayOfCards) {
if (cardObj?.card?.card && cardObj?.card?.card?.id === restaurantListing) {
Copy link

@akhintheruvath akhintheruvath Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to do cardObj?.card?.card && cardObj?.card?.card?.id ?
We could directly do only cardObj?.card?.card?.id right?

const resData =
cardObj.card?.card?.gridElements?.infoWithStyle?.restaurants;
setListOfRestraunt(resData);
setFilteredRestaurant(resData);
}
}
};

const onlineStatus = useOnlineStatus();
Expand Down