From 3bd6f562fbc89be3efb36d349a4b649c550cef95 Mon Sep 17 00:00:00 2001 From: mohammadpy8 Date: Mon, 28 Aug 2023 09:27:21 +0330 Subject: [PATCH] fix-project --- src/context/CartContextProvider.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/context/CartContextProvider.tsx b/src/context/CartContextProvider.tsx index dfc4667..ac63318 100644 --- a/src/context/CartContextProvider.tsx +++ b/src/context/CartContextProvider.tsx @@ -21,13 +21,11 @@ const CartContextProvider = ({ children }: CartProps) => { const [shop, setShop] = useState([]) useEffect(() => { - fetch('https://fakestoreapi.com/products') - .then((res) => res.json()) - .then((data) => { - console.log('data =>', data) - setShop(data) - }) - .catch((err) => console.log(err)) + (async () => { + const res = await fetch('https://fakestoreapi.com/products'); + const data = (await res.json()) as Produts[]; + setShop(data); + }); }, []) const addProduts = (id: number) => {