Last active
October 26, 2017 20:35
-
-
Save brybrophy/da16d78de7f7e56158837c1abcf52669 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
import axios from 'axios'; | |
import { displayUserFeedback } from './utils'; | |
export function handleClickGetAllUsers() { | |
axios.get('https://www.example.org/api/users', { | |
headers: { | |
Accept: 'application/json', | |
'Content-Type': 'application/json' | |
}, | |
timeout: 15000 | |
}) | |
.then(res => { | |
return res.data; | |
}) | |
.catch(() => { | |
// This is just a hypothetical utility function to display a toast | |
// notification to the user in the event of an error. | |
displayUserFeedback('There was an error retrieving the users.'); | |
}); | |
} | |
export function handleClickGetOneUser(userId) { | |
axios.get(`https://www.example.org/api/users/${usersId}`, { | |
headers: { | |
Accept: 'application/json', | |
'Content-Type': 'application/json' | |
}, | |
timeout: 15000 | |
}) | |
.then(res => { | |
return res.data; | |
}) | |
.catch(() => { | |
displayUserFeedback('There was an error retrieving the user.'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment