Skip to content

Commit b7f12e0

Browse files
committed
Update URL
1 parent a26c846 commit b7f12e0

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

src/app/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from "axios";
22

3-
const API_URL = import.meta.env.VITE_API_URL;
3+
const API_URL = "https://e-commerce-backend-sj1i.onrender.com";
44

55
// Set access token in local storage.
66
const setAccessToken = (accessToken) => {

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 = import.meta.env.VITE_API_URL;
4+
const API_URL = "https://e-commerce-backend-sj1i.onrender.com";
55

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

src/hooks/useGetProducts.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
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';
54

65
const useGetProducts = () => {
76

87
const dispatch = useDispatch();
98
const productData = useProducts();
109

11-
if (productData && productData.length > 0) return;
10+
if (productData && productData?.length > 0) return;
1211

1312

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

1916
export default useGetProducts;

0 commit comments

Comments
 (0)