{"action":"closed","issue":{"url":"https://api.github.com/repos/skellock/reduxsauce/issues/12","repository_url":"https://api.github.com/repos/skellock/reduxsauce","labels_url":"https://api.github.com/repos/skellock/reduxsauce/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/skellock/reduxsauce/issues/12/comments","events_url":"https://api.github.com/repos/skellock/reduxsauce/issues/12/events","html_url":"https://github.com/skellock/reduxsauce/issues/12","id":193794229,"number":12,"title":"Async Actions","user":{"login":"peterpme","id":1211905,"avatar_url":"https://avatars.githubusercontent.com/u/1211905?v=3","gravatar_id":"","url":"https://api.github.com/users/peterpme","html_url":"https://github.com/peterpme","followers_url":"https://api.github.com/users/peterpme/followers","following_url":"https://api.github.com/users/peterpme/following{/other_user}","gists_url":"https://api.github.com/users/peterpme/gists{/gist_id}","starred_url":"https://api.github.com/users/peterpme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterpme/subscriptions","organizations_url":"https://api.github.com/users/peterpme/orgs","repos_url":"https://api.github.com/users/peterpme/repos","events_url":"https://api.github.com/users/peterpme/events{/privacy}","received_events_url":"https://api.github.com/users/peterpme/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-06T15:00:40Z","updated_at":"2016-12-07T02:54:04Z","closed_at":"2016-12-07T02:54:04Z","body":"Hey!\r\n\r\nI'm using this because of Ignite, awesome work on that!\r\n\r\nI was wondering how I could handle async requests. I'm definitely missing a piece of the puzzle somewhere. \r\n\r\n```es6\r\n\r\nconst { Types, Creators } = createActions({\r\n  search: ['searchTerm'],\r\n  cancelSearch: null,\r\n  fetchRequest: null,\r\n  fetchSuccess: ['data'],\r\n  fetchFailure: ['error'],\r\n})\r\n\r\n// ...\r\n\r\nexport const onSuccess = (state: Object, {data}) => {\r\n return state.merge ({ results: data });\r\n}\r\n\r\n// ...\r\n\r\n[Types.FETCH_SUCCESS]: onSuccess,\r\n// ... etc\r\n```\r\n\r\nThis top part I think I understand, but where would something like this then go?\r\n\r\n```es6\r\n\r\nexport const searchRestos = () => (dispatch: Function, getState: Function) => {\r\n    dispatch(startFetching());\r\n\r\n    return api.getRestos()\r\n        .then(response => {\r\n            return dispatch(fetchedData({ response.data }));\r\n        })\r\n        .catch(response => dispatch(errorFetching(response.error)));\r\n};\r\n```\r\n\r\nThank you again!"}}
{"actor":{"display_login":"peterpme"}}