Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
axios interceptor for expired sessions with SweetAlert
axios.interceptors.response.use(response => {
return response;
}, error => {
if (error.response.status === 401) {
Swal.fire({
title: 'Session expired',
text: 'Please sign in again!',
type: 'error',
}).then(result => {
if (result.value) {
location.reload();
}
});
}
return Promise.reject(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment