title: How to Assign react redux state api get data using axios
body: <p>i used react 16+ and redux get jsonplaceholder fake data to assign posts state but not working. can't assign the state. how can i assign json values into state using concat method. i check lifecycle methods also but can't get the answer.</p>
  
  <p>Reducer</p>
  
  <pre><code>import * as actiontypes from './actions';
  import axios from 'axios';
  
  const initalstate = {
      counter: 0,
      posts: []
  };
  
  const reducer = (state = initalstate, action ) =&gt; {
      switch (action.type) {
          case actiontypes.actionFetchPost:
              axios.get('https://jsonplaceholder.typicode.com/posts')
                  .then(res =&gt; {
                      return {
                          ...state,
                          posts: state.posts.concat(res.data)
                      }
                  });
              break;
          default :
              return state;
      }
  };
  
  export default reducer;
  </code></pre>