Nuxt.js: how to prevent redirect when submit form and get 422

Created on 12 Mar 2019  路  8Comments  路  Source: nuxt/nuxt.js

i am new in nuxt and can't solve the problem when i try to submit form for getting 422 error should not go anywhere and should show error on console but its redirecting in error page with content

'Request failed with status code 422
An error occurred while rendering the page. Check developer tools console for details.'

how to prevent this

my code very is simple login

export default {
data() {
return {
form: {
email: '',
password: ''
}
}
},
methods: {
async submit() {
await this.$auth.login({
data: this.form
})
}
}
}

This question is available on Nuxt community (#c8815)

Most helpful comment

yeah i catched the error like this

.catch(error => {
      console.log(error.response.data)
})

its working like a charm

All 8 comments

This issue as been imported as question since it does not respect nuxt.js issue template. Only bug reports and feature requests stays open to reduce maintainers workload.
If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically.
Your question is available at https://cmty.app/nuxt/nuxt.js/issues/c8815.

i already posted to your website but no answer from your website

here is link

https://cmty.app/nuxt/nuxtjs.org/issues/c156

No solution to this problem.
Facing the same issue here :(

In my case i am using nuxt-auth

await this.$auth.loginWith("local",{
                    data: this.form
 });

@haideritx i have the same issue but when i use axios it works :

await this.$axios.$post('login',{email:this.email,password:this.password})

Any updates on this issue?

yeah i catched the error like this

.catch(error => {
      console.log(error.response.data)
})

its working like a charm

yeah i catched the error like this

.catch(error => {
      console.log(error.response.data)
})

its working like a charm

worked for me as well. Thank you.

its working like a charm. cheers

Was this page helpful?
0 / 5 - 0 ratings

Related issues

uptownhr picture uptownhr  路  3Comments

mikekidder picture mikekidder  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments

surmon-china picture surmon-china  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments