Skip to content

Commit a26c846

Browse files
committed
Update products URL
1 parent 1b92ac6 commit a26c846

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/app/product.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import axios from "axios";
22
import { getAccessToken } from "./auth";
33

4-
const API_URL = "http://localhost:5000";
4+
const API_URL = import.meta.env.VITE_API_URL;
55

66
export const fetchProducts = async () => {
77
try {

src/hooks/useGetProducts.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useDispatch } from 'react-redux';
22
import { getProducts } from '../features/product/productSlice.js';
33
import { useProducts } from './useStoreItems.js';
4+
import { useEffect } from 'react';
45

56
const useGetProducts = () => {
67

@@ -10,7 +11,9 @@ const useGetProducts = () => {
1011
if (productData && productData.length > 0) return;
1112

1213

13-
dispatch(getProducts());
14+
useEffect(() => {
15+
dispatch(getProducts());
16+
}, [])
1417
};
1518

1619
export default useGetProducts;

0 commit comments

Comments
 (0)