Here is the code, I have the object as it is in the backend but I don't understand what's unprocessable content. I want to know If I am doing the redux part right and I can't see the POST_DEPARTMENT in the redux dev tools so the api request is not a success I believe
departmentAction.js
export const postDepartment = (request) => async(dispatch) =>{
try{
const token = localStorage.getItem('bearer_token');
const res = await api.post(`v2/science/departments/`, request, {
headers:{
'Authorization': `Bearer ${token}`
}
}).then((res) =>{
console.log('response')
dispatch({
type: POST_DEPARTMENT,
payload: ''
})
.catch((err) => console.log(err))
});
}catch{
dispatch({
type: GET_ERRORS,
payload: res.data
})
}
}
CreateDepartment.js
const callApi = (formObj) => {
dispatch(postDepartment(formObj));
}
departmenttypes.js
export const POST_DEPARTMENT = "POST_DEPARTMENT";