title: ReactJS Redux Api Fetch
body: <p>I just need a little help with regards to fetching of data through an api</p>
  
  <p>currently I have this code in my container</p>
  
  <pre><code>    fetchAll: () =&gt; {
          Promise.resolve(token.getToken()).then( (response) =&gt; {
              let obj = {
               token_type: response.data.token_type,
               access_token: response.data.access_token   
              }
  
              apiFetch("http://dev.apiserver.com/api/all",{
                "method": "GET",
                "headers": {
                  "Authorization": `${obj.token_type} ${obj.access_token}`,
                  "userId": 1
                }
              })
              .then( (res) =&gt; {
                  return res.json();
              }).then( (json) =&gt; {
                  dispatch({
                      type: 'FETCH_ALL',
                      payload: json
                  })
              }).catch(function(err) {
                  console.log(err)
              })
          })
      } 
  </code></pre>
  
  <p>I'm calling the above function from componentWillMount(), I can successfully log the result in my console</p>
  
  <p>here is my reducer code</p>
  
  <pre><code>    const allReducer = (state: Immut = initialState, action: { type: string, payload: any }) =&gt; {
          switch (action.type) {
            case FETCH_ALL:
              let newState = state
              let payload = action.payload
  
              newState = Immutable.fromJS(payload)
              console.log(newState)
  
              return newState
          }
      }
  </code></pre>
  
  <p>the problem is that it doesn't update the state or re-render the components</p>