File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 1
1
import axios from "axios" ;
2
2
import { getAccessToken } from "./auth" ;
3
3
4
- const API_URL = "http://localhost:5000" ;
4
+ const API_URL = import . meta . env . VITE_API_URL ;
5
5
6
6
export const fetchProducts = async ( ) => {
7
7
try {
Original file line number Diff line number Diff line change 1
1
import { useDispatch } from 'react-redux' ;
2
2
import { getProducts } from '../features/product/productSlice.js' ;
3
3
import { useProducts } from './useStoreItems.js' ;
4
+ import { useEffect } from 'react' ;
4
5
5
6
const useGetProducts = ( ) => {
6
7
@@ -10,7 +11,9 @@ const useGetProducts = () => {
10
11
if ( productData && productData . length > 0 ) return ;
11
12
12
13
13
- dispatch ( getProducts ( ) ) ;
14
+ useEffect ( ( ) => {
15
+ dispatch ( getProducts ( ) ) ;
16
+ } , [ ] )
14
17
} ;
15
18
16
19
export default useGetProducts ;
You can’t perform that action at this time.
0 commit comments