51
51
< div class ="text-center ml-20 lg:text-left ">
52
52
< div class ="avatar " onclick ="my_modal_1.showModal() ">
53
53
< div id = "pic " class ="w-24 rounded-full shadow-2xl " >
54
- < img id ="profilePic " src ="http://localhost:8017/api/person/image/${userEmail} " onerror ="handleImageError() "/>
54
+ <!-- < img id="profilePic" src="http://localhost:8017/api/person/image/${userEmail}" onerror="handleImageError()"/> -- >
55
55
</ div >
56
56
</ div >
57
57
< dialog id ="my_modal_1 " class ="modal ">
@@ -116,8 +116,11 @@ <h2 class="text-2xl mb-4">Stock Predictions</h2>
116
116
117
117
118
118
< script >
119
- const decodedToken = parseJwt ( token ) ;
119
+
120
+ const token1 = getCookie ( "token" ) ;
121
+ const decodedToken = parseJwt ( token1 ) ;
120
122
const userEmail = decodedToken . sub ;
123
+ document . getElementById ( 'pic' ) . innerHTML = `<img id="profilePic" src="http://localhost:8017/api/person/image/${ userEmail } " onerror="handleImageError()"/>` ;
121
124
function handleImageError ( ) {
122
125
imgElement = document . getElementById ( 'profilePic' ) ;
123
126
@@ -290,6 +293,25 @@ <h2 class="text-2xl mb-4">Stock Predictions</h2>
290
293
. then ( response => response . json ( ) )
291
294
. then ( data => {
292
295
console . log ( data ) ;
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
293
315
if ( data . status !== 401 ) {
294
316
showSuccessMessage ( "Data successful! Your data has been created." ) ;
295
317
tickerInput . value = "" ;
@@ -317,7 +339,7 @@ <h2 class="text-2xl mb-4">Stock Predictions</h2>
317
339
318
340
fetch ( "http://localhost:8017/api/person/stats/" + userId , requestOptions )
319
341
. then ( response => {
320
- if ( ! response . ok ) {
342
+ if ( ! response . ok ) {
321
343
throw new Error ( 'Network response was not ok' ) ;
322
344
}
323
345
return response . json ( ) ;
@@ -371,7 +393,15 @@ <h2 class="text-2xl mb-4">Stock Predictions</h2>
371
393
fetch ( "http://localhost:8017/api/person/image/post" , requestOptions )
372
394
. then ( ( response ) => response . text ( ) )
373
395
. then ( ( result ) => console . log ( result ) )
396
+ . then ( ( blob ) => {
397
+ document . getElementById ( 'pic' ) . innerHTML = `<img id="profilePic" src="http://localhost:8017/api/person/image/${ userEmail } " onerror="handleImageError()"/>` ;
398
+ }
399
+
400
+ )
374
401
. catch ( ( error ) => console . error ( error ) ) ;
402
+
403
+
404
+
375
405
}
376
406
377
407
// function getProfilePicture() {
@@ -395,6 +425,6 @@ <h2 class="text-2xl mb-4">Stock Predictions</h2>
395
425
document . addEventListener ( "DOMContentLoaded" , function ( ) {
396
426
getStats ( ) ;
397
427
getName ( ) ;
398
- getProfilePicture ( ) ;
428
+ // getProfilePicture();
399
429
} ) ;
400
430
</ script >
0 commit comments