🐛 fix(api.tsx): add conditional check before calling login function to prevent errors when response data is missing access_token or refresh_token

This commit is contained in:
Cristhian Zanforlin Lousa 2023-09-11 09:10:44 -03:00
commit a2eadbedb1

View file

@ -33,7 +33,10 @@ function ApiInterceptor() {
}
const res = await renewAccessToken(refreshToken);
login(res?.data?.access_token, res?.data?.refresh_token);
if (res?.data?.access_token && res?.data?.refresh_token) {
login(res?.data?.access_token, res?.data?.refresh_token);
}
try {
if (error?.config?.headers) {
delete error.config.headers["Authorization"];