Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hyuna committed Aug 2, 2024
2 parents 8e5c84b + 2730495 commit cca950f
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,25 @@ instance.interceptors.response.use(
const { status } = error.response;
if (status === 401) {
const refreshToken = cookie.get("refresh_token");
if (refreshToken) {
try {
await axios
.put(`${BASEURL}/admin/refresh`, null, {
headers: {
"X-Refresh-Token": `${refreshToken}`,
},
})
.then((response) => {
const data = response.data;
cookie.set("access_token", data.access_token);
cookie.set("refresh_token", data.refresh_token);
});
} catch (refreshError) {
return Promise.reject(refreshError);
try {
await axios
.put(`${BASEURL}/admin/refresh`, null, {
headers: {
"X-Refresh-Token": `${refreshToken}`,
},
})
.then((response) => {
const data = response.data;
cookie.set("access_token", data.access_token);
cookie.set("refresh_token", data.refresh_token);
})
.catch(() => {
window.location.href = "login";
});
{
}
} catch (refreshError) {
return Promise.reject(refreshError);
}
}
}
Expand Down

0 comments on commit cca950f

Please sign in to comment.