{"size": 698, "ext": "js", "max_stars_repo_path": "app/actions/ProductCategory.js", "max_stars_repo_name": "amitnashtekar/onlinevegetables", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/actions/ProductCategory.js", "max_issues_repo_name": "amitnashtekar/onlinevegetables", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/actions/ProductCategory.js", "max_forks_repo_name": "amitnashtekar/onlinevegetables", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.347826087, "max_line_length": 64, "alphanum_fraction": 0.7464183381}
import { ProductCategoryAPI } from '../api';
import { productCategoryActions } from '../constants';
import { createAction } from './utils';

const {	
	GET_PRODUCT_CATEGORY_REQUEST,
	GET_PRODUCT_CATEGORY_SUCCESS,
	GET_PRODUCT_CATEGORY_FAILURE
} = productCategoryActions;

export function getProductCategories() {
	return dispatch => {
		dispatch(createAction(GET_PRODUCT_CATEGORY_REQUEST));
		ProductCategoryAPI.getProductCategories().then(result => {
			JSON.stringify(result);
			dispatch(createAction(GET_PRODUCT_CATEGORY_SUCCESS, result));
		}).catch(error => {
			console.log(error);
			dispatch(createAction(GET_PRODUCT_CATEGORY_SUCCESS,
				{data:[{id:1, name: 'Vegetables'}]}));
		});
	};
};