[Vuejs]-Error 422 Unprocessable Entity โ€“ Rails API VueJS From

0๐Ÿ‘

โœ…

You need to wrap post data in user object

{
  "user":
  {
    "email": "user@example.com",
    "password": "password"
  }
}

You can change your request

axios.post('http://localhost:3001/api/v1/users', {
    user: {
      email: this.email,
      password: this.password
    }
  })
  .then(res => (this.user = res.data))
  .catch((error) => {
    console.log(error)
  });

Leave a comment