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,

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


1 Like

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

Redux-Thunk and Redux-Saga.

1 Like