File tree Expand file tree Collapse file tree 3 files changed +4
-7
lines changed Expand file tree Collapse file tree 3 files changed +4
-7
lines changed Original file line number Diff line number Diff line change 1
1
import axios from "axios" ;
2
2
3
- const API_URL = import . meta . env . VITE_API_URL ;
3
+ const API_URL = "https://e-commerce-backend-sj1i.onrender.com" ;
4
4
5
5
// Set access token in local storage.
6
6
const setAccessToken = ( accessToken ) => {
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 = import . meta . env . VITE_API_URL ;
4
+ const API_URL = "https://e-commerce-backend-sj1i.onrender.com" ;
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' ;
5
4
6
5
const useGetProducts = ( ) => {
7
6
8
7
const dispatch = useDispatch ( ) ;
9
8
const productData = useProducts ( ) ;
10
9
11
- if ( productData && productData . length > 0 ) return ;
10
+ if ( productData && productData ? .length > 0 ) return ;
12
11
13
12
14
- useEffect ( ( ) => {
15
- dispatch ( getProducts ( ) ) ;
16
- } , [ ] )
13
+ dispatch ( getProducts ( ) ) ;
17
14
} ;
18
15
19
16
export default useGetProducts ;
You can’t perform that action at this time.
0 commit comments