React + redux error

after login button press I want to check whether fields are empty or not. But I faced this error.
Error: Actions must be plain objects. Use custom middleware for async actions. This is my code.

export const loginUser = (user) => {
  return (dispatch) => {
    console.log("checker");'/api/users/login', user)
      .then(res => {
      .catch(err => {
          type: GET_ERRORS,

You need other libraries to handle async actions in redux. Take a look at

Redux-Thunk and Redux-Saga.

1 Like