Last active
November 28, 2022 13:17
-
-
Save susanahernandezd/4debb92aab06c31d6c08ba3d00338f26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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