Skip to content

Instantly share code, notes, and snippets.

@Juan-Severiano
Created September 12, 2025 15:25
Show Gist options
  • Select an option

  • Save Juan-Severiano/b75b63b775000936ea9f6cf16ab06203 to your computer and use it in GitHub Desktop.

Select an option

Save Juan-Severiano/b75b63b775000936ea9f6cf16ab06203 to your computer and use it in GitHub Desktop.
api.interceptors.response.use(
(res) => res,
async (error) => {
if (error.response?.status === 401) {
// Aqui pode-se implementar algo para fazer quando der um erro 401 (ou qualquer outro)
// Ex. pode chamar uma rota de revalidação de token, ou simplesmente deslogar o user
}
return Promise.reject(error)
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment