File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -150,28 +150,33 @@ <h1 id="user" style="text-align: center"><b>Login to see your dashboard!</b></h1
150
150
< h2 style ="text-align: center "> Welcome to your dashboard!</ h2 >
151
151
< p id ="data " style ="text-align: center "> Loading...</ p >
152
152
153
-
154
-
155
153
< script >
156
154
async function loadUserData ( ) {
157
155
const username = localStorage . getItem ( "username" ) ;
158
156
159
157
if ( username ) {
160
- document . getElementById ( "user" ) . textContent = username ;
158
+ document . getElementById ( "user" ) . textContent = `Hello, ${ username } ` ;
161
159
162
160
try {
163
161
const res = await fetch ( `https://scratch-coding-hut-data.onrender.com/${ username } ` ) ;
164
162
const data = await res . json ( ) ;
165
163
164
+ console . log ( "Fetched data:" , data ) ; // Debugging line to check the data
165
+
166
166
if ( data ) {
167
167
document . getElementById ( "data" ) . textContent = JSON . stringify ( data ) ;
168
+ } else {
169
+ document . getElementById ( "data" ) . textContent = "No data available." ;
168
170
}
169
171
} catch ( error ) {
170
172
console . error ( "Error fetching data:" , error ) ;
171
173
document . getElementById ( "data" ) . textContent = "Failed to load data." ;
172
174
}
175
+ } else {
176
+ document . getElementById ( "data" ) . textContent = "Please log in." ;
173
177
}
174
178
}
179
+
175
180
function toggleMenu ( ) {
176
181
var menu = document . querySelector ( ".menu" ) ;
177
182
menu . style . display = menu . style . display === "flex" ? "none" : "flex" ;
You can’t perform that action at this time.
0 commit comments