Last active
November 11, 2019 22:04
-
-
Save Godofbrowser/76a3969f06736aa38b8a9c0902debb7e to your computer and use it in GitHub Desktop.
This gist is part of an article and may not covey the actual message on it's own. Link to article: https://medium.com/@ejjay/a-short-ajax-story-on-error-handlers-8baeeccbc062
This file contains hidden or 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
| import axios from 'axios'; | |
| import {notifier} from './util'; | |
| // Fetch some missing information | |
| axios.get('/api/articles/not-found').then(resp => { | |
| // So something with product information | |
| }).catch(error => { | |
| // 404 - Product not found error | |
| if (error.status === 404) { | |
| notifier.error('The requested article does not exist or it has been deleted') | |
| } | |
| if (error.status === 401) { | |
| notifier.error('Please login to view this article') | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment