title: TypeError: undefined is not an object (evaluating 'e.type') when i try to fetch a 2nd time
body: <p>I don't understand  every time i create or Sub to a post i can't render any of my fetch function and i have a TypeError: undefined is not an object (evaluating 'e.type'). So here is some code.</p>
  <p>I have a rails API and a react native fetching data in it. When i use Sub or create my rails send me status 200 message, so it work. But if i go back in my feedlist and choose any post or try to Logout i got this error:TypeError: undefined is not an object (evaluating 'e.type')</p>
  <p>sub</p>
  <pre><code>   export function onSub(data){
          return dispatch =&gt; {
              dispatch(fetchPostsPending());//to change?
              return fetch('localhost/api/v0/posts/'+data.id+'/records',{
              method:'POST',
              headers:{
                  &quot;access-token&quot;: data.accessToken,
                  &quot;token-type&quot;:   data.tokenType,
                  &quot;client&quot;:       data.client,
                  &quot;expiry&quot;:       data.expiry,
                  &quot;uid&quot;:          data.uid
                  }
              })
              .then((response)=&gt;{
                  if(response.ok){
                      if(response.headers.map['access-token'] == &quot;&quot;){
                          console.log(&quot;Response Token:&quot;,response.headers.map);
                      }
                      else{
                          console.log(&quot;New Token&quot;)
                          console.log(&quot;Response Token:&quot;,response.headers.map);
                          dispatch(updateToken(response.headers.map));
                      }
                      dispatch(fetchPostUpdate())
                  }
                  else{
                      return response.json()
                      .then((response)=&gt;{
                          console.log(&quot;Response:&quot;,response);
                          dispatch(fetchPostsError);
                      })
                  }
              })
              .catch((error)=&gt;{
                  console.log(&quot;error:&quot;,error);
                  dispatch(fetchPostsError);
              })
          }
      }
  </code></pre>
  <p>Create a Post</p>
  <pre><code>   export function onCreate(data){
          return dispatch =&gt; {
              dispatch(fetchPostsPending());
              return fetch('localhost/api/v0/posts',{
                  method:'POST',
                  headers:{
                  'Accept': 'application/json',
                  'Content-Type': 'application/json',
                  &quot;access-token&quot;: data.accessToken,
                  &quot;token-type&quot;:   data.tokenType,
                  &quot;client&quot;:       data.client,
                  &quot;expiry&quot;:       data.expiry,
                  &quot;uid&quot;:          data.uid
                  },
                  body: JSON.stringify({
                      &quot;title&quot;:data.title,
                      &quot;content&quot;:data.content,
                      &quot;created_by&quot;:data.created_by,
                      &quot;entry&quot;:data.entry,
                      &quot;category_id&quot;:data.category_id,
                      &quot;rdv&quot;:data.rdv,
                      &quot;tag1&quot;:data.tag1,
                      &quot;tag2&quot;:data.tag2,
                      &quot;tag3&quot;:data.tag3,
                      &quot;user_id&quot;:data.user_id
                  })
              })
                  .then((response) =&gt; {
                      if(response.ok){
                          if(response.headers.map['access-token'] == &quot;&quot;){
                              console.log(&quot;Response Token:&quot;,response.headers.map);
                          }
                          else{
                              console.log(&quot;New Token&quot;)
                              console.log(&quot;Response Token:&quot;,response.headers.map);
                              dispatch(updateToken(response.headers.map));
                          }
                      
                          response.json().then((responseJSON) =&gt; {
                              console.log(&quot;responseJSON :&quot;, JSON.stringify(responseJSON));
                              Alert.alert('New Post', 'Le Post a Bien ete créer');
                              dispatch(fetchPostCreate());
                              dispatch(fetchPostsPending());
                          })
                      }
                      else{
                          response.json().then((responseJSON) =&gt; {
                              console.log(&quot;responseJSON&quot;,JSON.stringify(responseJSON));
                              Alert.alert('Post ', 'something wrong');
                              dispatch(fetchPostsPending());
                          })
                      }
  
                  })
                  .catch((error) =&gt; {
                      console.log(&quot;error&quot;,error);
                      Alert.alert('Post', 'Some error occured, please retry');
                      dispatch(fetchPostsError(error));
                  });
              }
          }
  </code></pre>
  <p>Postreducer</p>
  <pre><code>import {FETCH_POST_PENDING, FETCH_POST_SUCCESS,FETCH_ONE_POST_SUCCESS, FETCH_POST_ERROR,
      FETCH_POST_CREATE,FETCH_POST_UPDATE,FETCH_POST_DELETE} from '../actions/postActions';
  
  const INITIAL_STATE = {
      pending: false,
      posts: [],
      onepost:[],
      create: false,
      update:false,
      delete:false,
      error: null
  }
  
  export default function post(state = INITIAL_STATE, action) {
      switch(action.type) {
          case FETCH_POST_PENDING: 
              return {
                  ...state,
                  pending: !state.pending
              }
          case FETCH_POST_SUCCESS:
              return {
              ...state,
              pending: false,
              posts:action.payload
              }
          case FETCH_ONE_POST_SUCCESS:
              return {
                  ...state,
                  pending: false,
                  onepost:action.payload
              }
          case FETCH_POST_CREATE:
              return {
                  ...state,
                  create: !state.create
              }
          case FETCH_POST_UPDATE:
              return {
                      ...state,
                      update: !state.update
                  }
          case FETCH_POST_DELETE:
              return {
                  ...state,
                  delete: !state.delete
              }
          case FETCH_POST_ERROR:
              return {
                  ...state,
                  pending: false,
                  error:action.error
              }
  
          default: 
              return state;
      }
  }
  </code></pre>
  <p>postAction</p>
  <pre><code>
  // Types
  export const FETCH_POST_PENDING = 'FETCH_POST_PENDING';
  export const FETCH_POST_SUCCESS = 'FETCH_POST_SUCCESS';
  export const FETCH_ONE_POST_SUCCESS = 'FETCH_ONE_POST_SUCCESS';
  export const FETCH_POST_ERROR = 'FETCH_POST_ERROR';
  export const FETCH_POST_CREATE = 'FETCH_POST_CREATE';
  export const FETCH_POST_UPDATE = 'FETCH_POST_UPDATE';
  export const FETCH_POST_DELETE = 'FETCH_POST_DELETE';
  
  
  //Actions
  
  export function fetchPostsPending() {
      return {
          type: FETCH_POST_PENDING
      }
  }
  //Index GetPosts
  export function fetchPostsSuccess(posts) {
      return {
          type: FETCH_POST_SUCCESS,
          payload: posts
      }
  };
  //Show
  export function fetchOnePostSuccess(onepost) {
    return {
        type: FETCH_ONE_POST_SUCCESS,
        payload: onepost
    }
  };
  export function fetchPostCreate(){
    type: FETCH_POST_CREATE
  };
  export function fetchPostUpdate(){
    type: FETCH_POST_UPDATE
  };
  export function fetchPostDelete(){
    type: FETCH_POST_DELETE
  };
  // manque ds ls Action Create Updates Deletes**
  
  export function fetchPostsError(error){
      return {
          type: FETCH_POST_ERROR,
          error: error
      }
  }
  </code></pre>
  <p>Thank you guys</p>