<commit_before>import fetch from 'isomorphic-fetch'

export default function fetchDispatch(url, options = {}, actions = {}) {
	// If there are only two parameters, the second one is actions
	if (actions === {}) {
		actions = options
		options = undefined
	}

	return (dispatch) => {

		if (typeof actions.request === 'function')  {
			actions.request()
		}

		return fetch(url, options)
			.then( (response) => {
				return response.json()
			})
			.then( (json) => {
				if (typeof actions.success === 'function') {
					dispatch(action(json))
				}

				return json
			})
			.catch( (err) => {
				if (typeof actions.fail === 'function') {
					dispatch(actions.fail(err))
				}
			})
	}
}<commit_msg>Fix actions success bug<commit_after>import fetch from 'isomorphic-fetch'

export default function fetchDispatch(url, options = {}, actions = {}) {
	// If there are only two parameters, the second one is actions
	if (actions === {}) {
		actions = options
		options = undefined
	}

	return (dispatch) => {

		if (typeof actions.request === 'function')  {
			actions.request()
		}

		return fetch(url, options)
			.then( (response) => {
				return response.json()
			})
			.then( (json) => {
				if (typeof actions.success === 'function') {
					dispatch(actions.success(json))
				}

				return json
			})
			.catch( (err) => {
				if (typeof actions.fail === 'function') {
					dispatch(actions.fail(err))
				}
			})

{'fraction_non_alphanumeric': 0.15833919774806474, 'fraction_numerical': 0.0, 'mean_word_length': 2.9610027855153205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2039553', 'n_tokens_mistral': 530, 'n_tokens_neox': 434, 'n_words': 117}