title: How to set a state in redux on page load
body: <p>To save on code typing, my code setup is exactly <a href="https://medium.com/@notrab/getting-started-with-create-react-app-redux-react-router-redux-thunk-d6a19259f71f" rel="nofollow noreferrer">like this</a>. Everything works fine. Now, let's say I need to pull in an initial code from my API for the <code>count</code> (state). How to do it?</p>
  
  <pre><code>// ./src/modules/counter.js
  
  import axios from 'axios'
  
  [...]
  
  const FETCHED_COUNT = []
  axios.get(&lt;http&gt;).then(res =&gt; FETCHED_COUNT.push(res.data))
  
  console.log( FETCHED_COUNT[0] ) // undefined
  
  const initialState = {
    count: FETCHED_COUNT,
    isIncrementing: false,
    isDecrementing: false
  }
  
  [...]
  </code></pre>
  
  <p>In the console log, I need my data from the api but it's nested a bit weired. It's an array so Im confused why it's undefined.</p>
  
  <p><strong>api data fetched:</strong></p>
  
  <pre><code>{
   "counts": [
     { "id": 1, "count": 20 },
     [...]
   ]
  }
  </code></pre>
  
  <p>My two cents say that this method is not used by you developers. How to set an initial state, with axios, feteched from your API? Basically, on page load, the state should be updated from an axios returned data</p>