All files / app/assets/javascripts/contributors/stores actions.js

100% Statements 7/7
100% Branches 0/0
100% Functions 4/4
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22          2x 5x   5x   4x   4x 4x     1x          
import createFlash from '~/flash';
import { __ } from '~/locale';
import service from '../services/contributors_service';
import * as types from './mutation_types';
 
export const fetchChartData = ({ commit }, endpoint) => {
  commit(types.SET_LOADING_STATE, true);
 
  return service
    .fetchChartData(endpoint)
    .then((res) => res.data)
    .then((data) => {
      commit(types.SET_CHART_DATA, data);
      commit(types.SET_LOADING_STATE, false);
    })
    .catch(() =>
      createFlash({
        message: __('An error occurred while loading chart data'),
      }),
    );
};