I am trying to include async / wait syntax in my Redux actions, but for some reason it does not work. I can’t understand for my whole life what happened to the following:
const actions = {
load: async (staff, date) => dispatch => {
const data = {
dateFrom: date,
dateTo: date,
person: staff,
personType: 'staff'
};
const events = utils.getDataPromise('json/events/load', data);
const classes = utils.getDataPromise('json/timetable/load', data);
dispatch({
type: actions.MYDAY_LOAD,
staff,
date: date || new Date(),
events: await events,
classes: await classes
});
},
}
The utils function uniquely returns a promise.
source
share