title: Redux fetch actions
body: <p>I create app with react and redux and I need to fetch data. Is there any way to reuse function getData() and reducer. My actions looks like this </p>
  
  <pre><code>importing constants
  
  const getDataRequested = () =&gt; {
    return {
      type: GET_DATA_REQUESTED
    };
  }
  
  const getDataDone = data =&gt; {
    return {
      type: GET_DATA_DONE,
      payload: data
    };
  }
  
  const getDataFailed = () =&gt; {
    return {
      type: GET_DATA_FAILED
    };
  }
  
  export const getData = () =&gt; dispatch =&gt; {
  
    dispatch(getDataRequested());
  
    fetch('url')
      .then(response =&gt; response.json())
      .then(data =&gt; {
        dispatch(getDataDone(data));
      })
      .catch(error =&gt; {
        dispatch(getDataFailed(error));
      })
  }
  </code></pre>
  
  <p>and reducer </p>
  
  <pre><code>importing constants
  
  const initialState = {
    isLoading: false,
    isError: false,
    data: [],
  }
  export default (state=initialState, action) =&gt; {
    switch (action.type) {
      case GET_DATA_REQUESTED:
        return { ...state, isLoading: true };
      case GET_DATA_DONE:
        return { ...state, isLoading: false, data: action.payload };
      case GET_DATA_FAILED:
        return { ...state, isLoading: false, isError: true}
      default:
        return state;
    }
  };
  </code></pre>
  
  <p>Every time I fetch something with different url I create new action and new reducer. Is it ok or there is some way to reuse it?</p>