-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98fa81c
commit 12c0c32
Showing
1 changed file
with
6 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
export const getError = (error) => { | ||
const errorMessage = "API Error, please try again."; | ||
|
||
if (!error.response) { | ||
console.error(`API ${error.config.url} not found`); | ||
return errorMessage; | ||
} | ||
if (error.response && process.env.NODE_ENV === "development") { | ||
if (process.env.NODE_ENV === "development") { | ||
console.error(error.response.data); | ||
console.error(error.response.status); | ||
console.error(error.response.headers); | ||
} | ||
if (error.response.data && error.response.data.errors) { | ||
return error.response.data.errors; | ||
} | ||
return "API Error, please try again."; | ||
|
||
return errorMessage; | ||
}; |