Guest User

Untitled

a guest
Feb 25th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. public render () {
  2.  
  3. const { axiosError } = this.state
  4.  
  5. return (
  6. {axiosError &&
  7. withAxiosErrorHandled(axiosError)(Alert)
  8. }
  9. )
  10. }
  11.  
  12. export const AlertWithAxiosErrorHandled = (axiosError: AxiosError) => {
  13. let text
  14. const { code, response } = axiosError
  15.  
  16. if (response) {
  17. switch (code) {
  18. case '404':
  19. text = AppConfig.messages[404]
  20. break
  21.  
  22. default:
  23. text = AppConfig.messages.default
  24. }
  25. } else {
  26. text = AppConfig.messages.default
  27. }
  28.  
  29. return <Alert text={text} />
Add Comment
Please, Sign In to add comment