Skip to content

Commit b551525

Browse files
author
Vivek Vishal
authored
Merge pull request #6470 from layer5io/vishalvivekm-patch-3
chore: handle missing or invalid token without throwing error
2 parents 06a1204 + 752fdba commit b551525

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/sections/General/Navigation/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ const Navigation = () => {
187187
const fetchData = async () => {
188188
try {
189189
const token = getCookieValue("provider_token");
190+
if (!token) { // no token: don't proceed
191+
return;
192+
}
190193
const response = await axios.get(CLOUD_USER_API, {
191194
headers: {
192195
Authorization: `Bearer ${token}`,
@@ -200,7 +203,12 @@ const Navigation = () => {
200203
const data = response.data;
201204
setUserData(data);
202205
} catch (error) {
203-
console.error("There was a problem with your fetch operation:", error);
206+
if (error?.response?.status === 401) {
207+
// unauthorized token
208+
} else {
209+
// only for debugging purposes, no need to log
210+
// console.error("There was a problem with your fetch operation:", error);
211+
}
204212
}
205213
};
206214

0 commit comments

Comments
 (0)