Skip to content

Commit

Permalink
fix-project
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadpy8 committed Aug 28, 2023
1 parent b46cb72 commit 3bd6f56
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/context/CartContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ const CartContextProvider = ({ children }: CartProps) => {
const [shop, setShop] = useState<Produts[]>([])

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) => {
Expand Down

0 comments on commit 3bd6f56

Please sign in to comment.