React Native: Possible Unhandled Promise Rejection (id: 0): TypeError: undefined is not an object
React Native: Possible Unhandled Promise Rejection (id: 0): TypeError: undefined is not an object
我有一个克隆的 React Native 应用程序,在我的模拟器上注册到该应用程序后,我在屏幕底部看到这个黄色错误,上面写着:
Possible Unhandled Promise Rejection (id: 0): TypeError: undefined is
not an object (evaluating 'data.Items')
我认为它必须引用此文件中的一个或所有这些动作创建者:
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}));
}
});
};
}
我以前写过异步动作创建器,但我看不出这些有什么问题。是 data
未定义吗?如果是这样,我的问题是,如果在应用程序的其他区域使用 data
没有明显错误,这怎么可能?
您的数据结果未定义...与您的 redux 操作无关
检查 api-endpoint 的一种简单直接的方法是 postman ...
我有一个克隆的 React Native 应用程序,在我的模拟器上注册到该应用程序后,我在屏幕底部看到这个黄色错误,上面写着:
Possible Unhandled Promise Rejection (id: 0): TypeError: undefined is not an object (evaluating 'data.Items')
我认为它必须引用此文件中的一个或所有这些动作创建者:
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}));
}
});
};
}
我以前写过异步动作创建器,但我看不出这些有什么问题。是 data
未定义吗?如果是这样,我的问题是,如果在应用程序的其他区域使用 data
没有明显错误,这怎么可能?
您的数据结果未定义...与您的 redux 操作无关 检查 api-endpoint 的一种简单直接的方法是 postman ...