K
K
Kirill Kontorovich2019-04-02 18:03:44
Vue.js
Kirill Kontorovich, 2019-04-02 18:03:44

How to get error body Laravel - Vue?

The bottom line is this, I get a validation failed error. In the browser on the network, I see the error
5ca37918a9f9b601357518.png
But when I try to print it to the console, I get this
5ca3795028c92825374182.png
Because of this, I can not get error messages. Maybe someone knows why and how to fix this
Code in the controller:

protected function registerUser(Request $request)
    {
        $this->validate($request, [
            'email' => 'required|email|max:255|unique:users',
            'phone' => 'required|max:255|unique:users',
            'password' => 'required|min:6|confirmed',
        ]);

Code in vue.js:
requests.auth.register(this.form)
                    .then((data) => {
                        console.log(data)
                        this.successMessage = data.data.message;
                        setTimeout(()=>{
                            this.$router.push({name: 'login-index'})
                        },4000)
                    })
                    .catch((response)=>{
                        console.log(response);
                        this.errors = response.data.errors;
                    })

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jazzus, 2019-04-02
@ishimitsu

i get errors like this

.catch((error)=> {
    this.errors  = error.response.data.errors;
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question