score:1

afaik, dispatching action is synchronous so you can't await it. so the issue is coming from your dispatching part. it should be fixed if you do something like this

export const createentity: icrudputaction<realm> = entity => async dispatch => {
  const result = await axios.post(apiurl, cleanentity(entity));
  dispatch({
    type: action_types.create_realm,
    payload: result.data,
  });
  dispatch(getentities());
  return result;
};

you need await for your api call to finish then dispatch an action which is sync call. and 4xx errors occur when it's a client side error, so you need to check your post data format, headers, etc because of which the server might reject your request with error.


Related Query

More Query from same tag