mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-21 21:29:25 +00:00
chore: wrap function in try catch
This commit is contained in:
@@ -57,12 +57,17 @@ const useAuth = () => {
|
|||||||
const token = localStorage.getItem("token");
|
const token = localStorage.getItem("token");
|
||||||
(async () => {
|
(async () => {
|
||||||
if (token) {
|
if (token) {
|
||||||
const { data } = await api.post("/auth/refresh_token");
|
try {
|
||||||
api.defaults.headers.Authorization = `Bearer ${JSON.parse(token)}`;
|
const { data } = await api.post("/auth/refresh_token");
|
||||||
setIsAuth(true);
|
api.defaults.headers.Authorization = `Bearer ${data.token}`;
|
||||||
setUser(data.user);
|
setIsAuth(true);
|
||||||
|
setUser(data.user);
|
||||||
|
setLoading(false);
|
||||||
|
} catch (err) {
|
||||||
|
toastError(err);
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setLoading(false);
|
|
||||||
})();
|
})();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user