File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -30,14 +30,16 @@ router
30
30
. resolve ( ) ;
31
31
32
32
const userJWTToken = JSON . parse ( localStorage . getItem ( "user" ) ) ;
33
- fetch ( "http://localhost:5552/api/hello" , {
34
- headers : {
35
- "Content-type" : "application/json; charset=UTF-8" ,
36
- // attaching the JWT token to the request
37
- Authorization : "Bearer " + userJWTToken . accessToken ,
38
- } ,
39
- } )
40
- . then ( ( response ) => response . text ( ) )
41
- . then ( ( data ) => {
42
- console . log ( data ) ;
43
- } ) ;
33
+ if ( userJWTToken ) {
34
+ fetch ( "http://localhost:5552/api/hello" , {
35
+ headers : {
36
+ "Content-type" : "application/json; charset=UTF-8" ,
37
+ // attaching the JWT token to the request
38
+ Authorization : "Bearer " + userJWTToken . accessToken ,
39
+ } ,
40
+ } )
41
+ . then ( ( response ) => response . text ( ) )
42
+ . then ( ( data ) => {
43
+ console . log ( data ) ;
44
+ } ) ;
45
+ }
You can’t perform that action at this time.
0 commit comments