简体   繁体   中英

React Native: Possible Unhandled Promise Rejection (id: 0): TypeError: undefined is not an object

I have a React Native application that I cloned and after registering into the app on my simulator, I get this yellow error at the bottom of the screen which says:

Possible Unhandled Promise Rejection (id: 0): TypeError: undefined is not an object (evaluating 'data.Items')

I believe it has to be referencing one or all of these action creators in this file:

export function fetchPrefences({Key}) {
  return dispatch => {
    const url = `${endpoints.v2.INDIVIDUALS}/${Key}/preferences`;
    requester.sendGet(url).then(data => {
      const payload = helpers.sortPreferences(data);
      dispatch({
        type: types.SET_USER_PREFERENCES,
        payload,
      });
    });
  };
}

export function fetchTopics() {
  return dispatch => {
    requester.sendGet(endpoints.TOPICS_OF_CONCERN).then(data => {
      dispatch({
        type: types.SET_USER_TOPICS,
        payload: data.Items,
      });
    });
  };
}

export function handleUpdateTopics({topics, involved}, updateBoth = false) {
  return dispatch => {
    return requester
      .sendPut(endpoints.TOPICS_OF_CONCERN, {
        Items: topics,
      })
      .then(data => {
        dispatch({
          type: types.SET_USER_TOPICS,
          payload: data.Items,
        });
        if (updateBoth) {
          dispatch(handleUpdatePreferences({involved}));
        }
      });
  };
}

I have written asynchronous action creators in the past, but I can't see what is wrong with these. Is it that data is undefined? If so, my question would be, how is this possible if in other areas of the application data is being used with no obvious errors?

您的数据结果是不确定的...与您的redux操作无关。 邮递员是一种简单而直接的检查api端点的方法...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM