Skip to content

Commit d3f0d80

Browse files
committed
[FIX] Swiggy API update - 27 July 2023
1 parent 5b0b8d7 commit d3f0d80

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/components/Body.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ const Body = () => {
2828
const json = await data.json();
2929

3030
// Optional Chaining
31-
setListOfRestraunt(json?.data?.cards[2]?.data?.data?.cards);
32-
setFilteredRestaurant(json?.data?.cards[2]?.data?.data?.cards);
31+
setListOfRestraunt(
32+
json?.data?.cards[5]?.card?.card?.gridElements?.infoWithStyle?.restaurants
33+
);
34+
setFilteredRestaurant(
35+
json?.data?.cards[5]?.card?.card?.gridElements?.infoWithStyle?.restaurants
36+
);
3337
};
3438

3539
const onlineStatus = useOnlineStatus();
@@ -99,13 +103,13 @@ const Body = () => {
99103
<div className="flex flex-wrap">
100104
{filteredRestaurant.map((restaurant) => (
101105
<Link
102-
key={restaurant.data.id}
103-
to={"/restaurants/" + restaurant.data.id}
106+
key={restaurant?.info.id}
107+
to={"/restaurants/" + restaurant?.info.id}
104108
>
105-
{restaurant.data.promoted ? (
106-
<RestaurantCardPromoted resData={restaurant} />
109+
{restaurant?.info.promoted ? (
110+
<RestaurantCardPromoted resData={restaurant?.info} />
107111
) : (
108-
<RestaurantCard resData={restaurant} />
112+
<RestaurantCard resData={restaurant?.info} />
109113
)}
110114
</Link>
111115
))}

src/components/RestaurantCard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const RestaurantCard = (props) => {
1313
cuisines,
1414
costForTwo,
1515
deliveryTime,
16-
} = resData?.data;
16+
} = resData;
1717

1818
return (
1919
<div className="m-4 p-4 w-[250px] rounded-lg bg-gray-100 hover:bg-gray-200">

0 commit comments

Comments
 (0)