Skip to content

Commit 26df20a

Browse files
committed
fix: handle potential errors when retrieving token in Axios request interceptor
1 parent 2dbefff commit 26df20a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

web/src/lib/axios/ClientAxios.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ const ClientAxios = axios.create({
1212
// Add a request interceptor to add the token to the request
1313
ClientAxios.interceptors.request.use(
1414
(config) => {
15-
const token = getTokenLocal();
15+
try {
16+
const token = getTokenLocal();
1617

17-
config.headers.authorization = `Bearer ${token}`;
18+
config.headers.authorization = `Bearer ${token}`;
1819

19-
return config;
20+
return config;
21+
} catch {
22+
return config;
23+
}
2024
},
2125
(error) => {
2226
return Promise.reject(error);

0 commit comments

Comments
 (0)