title: React Axios Request failed with status code 400
body: <p>I'm trying to connect to the api with axios, but it gives 400 error. how do i solve it?</p>
  <h2>Api</h2>
  <pre><code>    [Route(&quot;api/[controller]&quot;)]
      [ApiController]
      public class UserController : ControllerBase
      {
          private readonly JwtDbContext context;
          private readonly IConfiguration configuration;
  
          public UserController(JwtDbContext context, IConfiguration configuration)
          {
              this.context = context;
              this.configuration = configuration;
          }
  
        
          [HttpPost(&quot;[action]&quot;)]
          public async Task&lt;ActionResult&lt;Token&gt;&gt; Login([FromForm] UserLogin userLogin)
          {
              User user = await context.Users.Include(u =&gt; u.UserRoles).ThenInclude(ur =&gt; ur.Role).FirstOrDefaultAsync(x=&gt;x.Email == userLogin.Email &amp;&amp; x.Password == userLogin.Password);
              
              if(user != null)
              {
                  TokenHandler tokenHandler = new TokenHandler(configuration);
                  Token token = tokenHandler.CreateAccessToken(user);
                  user.RefreshToken = token.RefreshToken;
                  user.RefrestTokenEndDate = token.Expiration.AddMinutes(3);
                  await context.SaveChangesAsync();
                  return Ok(token);
              }
  
              return null;
          }
  }
  </code></pre>
  <h2>React</h2>
  <pre><code> var config = {
          method: 'post',
          url: 'https://localhost:7024/api/User/Login',
          headers: { 
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
          },
          userLogin : JSON.stringify({
            'Email': document.getElementById('userName').value,
            'Password': document.getElementById('password').value
          })
        };
  
        Axios(config)
        .then(function (response) {
          console.log(JSON.stringify(response.data));
        })
        .catch(function (error) {
          console.log(error);
        });
  </code></pre>
  <p>I got this code from postman. postman request is going. but react is not going. Thanks in advance. ................................</p>