Skip to content

Instantly share code, notes, and snippets.

@abimaelmartell
Created June 12, 2023 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abimaelmartell/7348a05c2a19dde1a308c3e4cbac28b8 to your computer and use it in GitHub Desktop.
Save abimaelmartell/7348a05c2a19dde1a308c3e4cbac28b8 to your computer and use it in GitHub Desktop.
axios.interceptors.response.use(
(response) => response,
(error) => {
if (defaultAxios.isAxiosError(error)) {
throw new Error(
`Failed Request to ${error.config.url} with ${JSON.stringify(
error.config.data
)} with status ${error.response?.status} and data ${JSON.stringify(
error.response?.data
)}`
)
}
throw error
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment