这是我在reducer中的initialState
const initialState = {
ids:[],
periodData: {}
}
我想更新备注 periodID:3477dac1-d14a-4aef-b544-d8945b2442b9“从”test“到”test1“
这是我要更新的行动:
export function updatePeriod(data){
return function(dispatch){
let formData = new FormData();
formData.append("periodID", data.periodID);
formData.append("periodName", data.periodName);
formData.append("startDate", fecha.format(data.startDate, 'YYYY-MM-DD'));
formData.append("endDate", fecha.format(data.endDate, 'YYYY-MM-DD'));
formData.append("remark", data.remark);
formData.append("isActive", 1);
dispatch({type: PERIOD_FETCHING}); //Loading Indicator Appeared
axios.post(`${ROOT_URL}/api/setup/createPeriod`,formData,
{
headers:{authorization:`Bearer `+localStorage.getItem('laravel_user_token')}
}
).then(response => {
let result = {
"periodID": data.periodID,
"periodName": data.periodName,
"startDate": fecha.format(data.startDate, 'YYYY-MM-DD'),
"endDate": fecha.format(data.endDate, 'YYYY-MM-DD'),
"remark": data.remark,
"isActive": '1'
}
console.log(normalize(result, schema.periodSchema));
dispatch({type: PERIOD_UPDATE,
payload: normalize(result, schema.periodSchema)
});
dispatch({type: PERIOD_FETCHED}) //Loading Indicator Disappeared
}).catch((e)=>{
console.log(e)
dispatch({type: PERIOD_FETCH_ERROR,
});
});
}
}
这是
的结果console.log(normalize(result,schema.periodSchema));
我仍然对我的reducer如何在我的商店中更新(PERIOD_UPDATE)ids和periodData感到困惑。