Skip to content

Instantly share code, notes, and snippets.

@scott-riley
Created February 14, 2016 00:00
Show Gist options
  • Save scott-riley/4b960201c97e049956fa to your computer and use it in GitHub Desktop.
Save scott-riley/4b960201c97e049956fa to your computer and use it in GitHub Desktop.
// actions/index.js
/* Team actions */
export function fetchTeams() {
const request = axios.get(`${ROOT_URL}/teams${ACCESS_TOKEN}`);
return {
type: FETCH_TEAMS,
payload: request
};
}
// reducer_teams.js
import {FETCH_TEAMS} from 'actions/index';
import {INITIAL_STATE} from './index'; // these both import fine
export default function(state = INITIAL_STATE, action) {
switch(action.type) {
case FETCH_TEAMS:
console.log(action.payload.data.data; // this console.logs at the right time so I know FETCH_TEAMS is being called when it should
return {
...state,
teams: action.payload.data.data,
}
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment