function fetchSuggestedWorkouts() {
  return function(dispatch) {
    dispatch({type: 'LOADING_WORKOUTS'})
    return fetch(`/api/workouts`)
      .then(resp => resp.json())
      // Dispatches JSON response containing workouts to store, but with different action type
      .then(workouts => dispatch({type: 'FETCH_SUGGESTED_WORKOUTS', payload: workouts}))
  }
}
// Retrieves workouts index resource from Rails API
Retrieves workouts index resource from Rails API
Retrieves workouts index resource from Rails API
function fetchSuggestedWorkouts() {
  return function(dispatch) {
    dispatch({type: 'LOADING_WORKOUTS'})
    return fetch(`/api/workouts`)
      .then(resp => resp.json())
      .then(workouts => dispatch({type: 'FETCH_SUGGESTED_WORKOUTS', payload: workouts}))
  }
}
function fetchSuggestedWorkouts ( ) { return function ( dispatch ) { dispatch ( { type : 'LOADING_WORKOUTS' } ) return fetch ( ` ` ) . then ( resp => resp . json ( ) ) . then ( workouts => dispatch ( { type : 'FETCH_SUGGESTED_WORKOUTS' , payload : workouts } ) ) } }
Retrieves workouts index resource from Rails API
Retrieves workouts index resource from Rails API
// Dispatches JSON response containing workouts to store, but with different action type