Created
July 6, 2017 05:23
-
-
Save itzsaga/1cba5578104707b9b4431778f9ab6d86 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
// fetch places | |
function fetchPlaces () { | |
return (dispatch) => { | |
dispatch({type: 'FETCH_PLACES'}) | |
return fetch('http://localhost:3001/api/places') | |
.then(response => { | |
response.json() | |
.then(json => { | |
dispatch({type: 'RECEIVED_PLACES', payload: json}) | |
}) | |
}) | |
.catch((err) => { | |
dispatch({type: 'FETCH_PLACES_ERROR', payload: err}) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment