Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const actionsCreator = {
- `fetchUsers: () => {
- return function (dispatch) {
- dispatch(actionCreators.requestUsers());
- return fetch("https://jsonplaceholder.typicode.com/users")
- .then(
- response => {
- if (response.ok) {
- return response.json()
- }
- throw new Error("404");
- }
- )
- .then(json =>
- dispatch(actionCreators.requestUsersSuccess(json))
- ).catch(error => {
- console.error(error);
- dispatch(actionCreators.requestUsersError(error))
- })
- }
- }`
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement