title: Request failed with status code 400 with axios
body: <p>I am trying to use the login API I made using node, however, whenever I call the API using Axios, it gives me a request failed in the console.</p>
  <p>This is how I use axios to call my method:</p>
  <pre><code>   axios
        .post(
          &quot;http://localhost:8080/staffMember/login&quot;,
          {
            email: &quot;Fred@gmail.com&quot;,
            password: &quot;Flintstone&quot;,
          },
          {
            headers: {
              &quot;Content-Type&quot;: &quot;application/json&quot;,
            },
          }
        )
        .then((response) =&gt; {
          console.log(response);
        })
        .catch((error) =&gt; {
          console.log(error.message);
        });
    };
  </code></pre>
  <p>And this is my login page and console :</p>
  <p><a href="https://i.stack.imgur.com/docn2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/docn2.png" alt="enter image description here" /></a></p>
  <p>This is my backend configuration:</p>
  <pre><code>require(&quot;dotenv&quot;).config();
  const mongoose = require(&quot;mongoose&quot;);
  const express = require(&quot;express&quot;);
  const app = express();
  const staffMember = require(&quot;./routers/staffMember.router.js&quot;);
  const hrMember = require(&quot;./routers/hrMember.router.js&quot;);
  const academicMember = require(&quot;./routers/academic members/academicMember.router&quot;);
  const headOfDepartment = require(&quot;./routers/academic members/headOfDepartment.router&quot;);
  const courseInstructor = require(&quot;./routers/academic members/courseInstructor.router&quot;);
  const courseCoordinator = require(&quot;./routers/academic members/courseCoordinator.router&quot;);
  var cors = require(&quot;cors&quot;);
  app.use(cors());
  
  mongoose
    .connect(process.env.DATABASE_CONN_STRING, {
      useNewUrlParser: true,
      useUnifiedTopology: true,
      useFindAndModify: false,
      useCreateIndex: true,
    })
    .then(() =&gt; {
      console.log(&quot;DB connected&quot;);
    })
    .catch(() =&gt; {
      console.log(&quot;DB connection failed&quot;);
    });
  
  app.use(express.json());
  app.use(express.urlencoded({ extended: false }));
  
  app.use(&quot;/staffMember&quot;, staffMember);
  app.use(&quot;/hrMember&quot;, hrMember);
  app.use(&quot;/academicMember&quot;, academicMember);
  app.use(&quot;/courseInstructor&quot;, courseInstructor);
  app.use(&quot;/courseCoordinator&quot;, courseCoordinator);
  app.use(&quot;/headOfDepartment&quot;, headOfDepartment);
  
  module.exports = app;
  </code></pre>