File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -134,13 +134,22 @@ <h2 style="text-align:center;">Welcome to your dashboard</h2>
134134 < p id ="data " style ="text-align:center; "> COMING SOON</ p >
135135
136136 < script >
137- const username = localStorage . getItem ( 'username' ) ;
138- if ( username ) {
139- document . getElementById ( 'user' ) . textContent = username ;
140- const res = await fetch ( 'scratch-coding-hut-data.onrender.com' )
141- if ( res . json ( ) ) {
142- document . getElementById ( 'data' ) . textContent = res . json ( )
137+ const username = localStorage . getItem ( 'username' ) ;
138+ if ( username ) {
139+ document . getElementById ( 'user' ) . textContent = username ;
140+
141+ try {
142+ const res = await fetch ( 'https://scratch-coding-hut-data.onrender.com' ) ;
143+ const data = await res . json ( ) ;
144+
145+ if ( data ) {
146+ document . getElementById ( 'data' ) . textContent = JSON . stringify ( data ) ;
143147 }
148+ } catch ( error ) {
149+ console . error ( 'Error fetching data:' , error ) ;
150+ }
151+ }
152+
144153 function toggleMenu ( ) {
145154 var menu = document . querySelector ( '.menu' ) ;
146155 menu . style . display = menu . style . display === 'flex' ? 'none' : 'flex' ;
You can’t perform that action at this time.
0 commit comments