Skip to content

Instantly share code, notes, and snippets.

@susanahernandezd
Last active November 28, 2022 13:17
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 susanahernandezd/4debb92aab06c31d6c08ba3d00338f26 to your computer and use it in GitHub Desktop.
Save susanahernandezd/4debb92aab06c31d6c08ba3d00338f26 to your computer and use it in GitHub Desktop.
try {
return await this.http.get(`/whatever`, {
validateStatus: status => status === 301 //this throws an error if status code is not = 301
});
} catch (e) {
const error = {
isAxiosError: true,
response: {
status: HttpStatusCode.INTERNAL_SERVER_ERROR,
data: [
{
code: 'UNEXPECTED_ERROR',
message: 'API responded with Internal Server Error'
}
]
}
} as AxiosError;
throw error;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment