Skip to content

Instantly share code, notes, and snippets.

@jks8787 jks8787/actions.js Secret
Last active Aug 2, 2017

Embed
What would you like to do?
actions and types for react+ redux -- Medium Article gist
import * as types from './actionTypes';
function url() {
return 'www.url.com';
}
export function receiveStuff(json) {
return {type: types.RECEIVE_STUFF, stuff: json.stuff};
}
export function fetchStuff() {
return dispatch => {
return fetch(url(), {
method: 'GET',
mode: 'cors',
credentials: 'include',
headers: {
'x-api-key': apiKey,
'Accept': 'application/json'
}
})
.then(response => response.json())
.then(json => dispatch(receiveStuff(json)));
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.