Skip to content

Commit f20b49f

Browse files
committed
asd
1 parent e98e540 commit f20b49f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

index.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ router
3030
.resolve();
3131

3232
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+
}

0 commit comments

Comments
 (0)