score:0

export const createUser = (user, callBack) => {
    api.defaults.headers.common['Authorization'] = state.token.token;
    api.post("/users/create", user)
        .then(response => {
            //dispach(createUserSuccess(response.data));
            if (callBack !== undefined) {
                callBack(response.data, null);
            }
        }).catch(error => {
            error = errorManager(error);
            //dispach(createUserFailure(error));
            if (callBack !== undefined) {
                callBack(null, error);
            }
        });
}

score:2

export function postAction(url,data) {
  return function(dispatch) {
      //You need to return your promise.
      return axios({
          method:'post',
          url:API_URL + url,
          headers: {'event': 55},
          data: data,
      })
    .then(response => {
      dispatch({
        type: POST_ACTION,
        payload: response.data
      });
      return response;
    })
    .catch((error) => {
      console.log(error);
    })
  }
}

Related Query

More Query from same tag