WikiEducationFoundation/WikiEduDashboard

View on GitHub
app/assets/javascripts/actions/user_courses_actions.js

Summary

Maintainability
A
1 hr
Test Coverage
C
75%
import API from '../utils/api.js';
import { RECEIVE_USER_COURSES, API_FAIL } from '../constants';

export const fetchCoursesForUser = userId => dispatch =>
  API.fetchUserCourses(userId)
    .then(resp =>
      dispatch({ type: RECEIVE_USER_COURSES, payload: { data: resp } }))
      .catch(response => (dispatch({ type: API_FAIL, data: response })));