【发布时间】:2019-08-24 20:56:44
【问题描述】:
我正在尝试映射object,但同时它给了我以下错误:TypeError: values.map is not a function。我是 React 开发的新手。
我在Redux中使用这个方法method
代码
export function createEvent(values) {
let modifyValue = values.map(newValue => {
return {
subject: newValue.id,
taskType: newValue.tasktype,
time: newValue.time,
date: newValue.date,
notes: newValue.notes,
createdAt: newValue.createdAt,
updatedAt: newValue.updatedAt,
deletedAt: newValue.deletedAt,
userId: newValue.userId,
customerId: localStorage.getItem("customerValue"),
start: newValue.start,
end: newValue.end
};
});
return dispatch => {
axios
.post("api/diary/create", modifyValue)
.then(response => {
return dispatch({ type: SET_DIARY_TASK_SUCCESS, data: response });
})
.catch((xhr, status, err) => {
return dispatch({ type: SET_DIARY_TASK_FAILURE, data: xhr });
});
};
}
【问题讨论】:
-
您是否检查过
map之前的值中有哪些数据? -
什么是
values,它来自哪里? -
@NeelRathod 对象
-
@Cristy It 对象
-
当我在本地存储中控制台或存储
values时,它会给我结果[object object]
标签: javascript reactjs ecmascript-6 react-redux javascript-objects