File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,13 @@ import axios from 'axios';
6
6
import PortfolioAnalytics from '../components/dashboard/PortfolioAnalytics' ;
7
7
import StockDetail from '../components/dashboard/StockDetail' ;
8
8
9
- const API_BASE_URL = 'http://localhost:5000/api' ;
9
+ const API_BASE_URL = import . meta. env . VITE_API_BASE_URL || 'https://portfolio-tracker-backend-y7ne.onrender.com/api' ;
10
+
11
+ // Create axios instance with base URL
12
+ const api = axios . create ( {
13
+ baseURL : API_BASE_URL ,
14
+ timeout : 10000
15
+ } ) ;
10
16
11
17
const containerVariants = {
12
18
hidden : { opacity : 0 } ,
@@ -122,10 +128,13 @@ export default function Dashboard({ theme: propTheme }) {
122
128
123
129
const fetchStocks = async ( ) => {
124
130
try {
125
- const response = await axios . get ( `${ API_BASE_URL } /stocks` ) ;
131
+ console . log ( 'Fetching stocks from:' , API_BASE_URL ) ;
132
+ const response = await api . get ( '/stocks' ) ;
133
+ console . log ( 'Stocks fetched successfully:' , response . data ) ;
126
134
setStocks ( response . data ) ;
127
135
setLoading ( false ) ;
128
136
} catch ( err ) {
137
+ console . error ( 'Error fetching stocks:' , err ) ;
129
138
setError ( 'Failed to fetch stocks' ) ;
130
139
setLoading ( false ) ;
131
140
}
You can’t perform that action at this time.
0 commit comments