Ms123Robot
Ms123Robot

Reputation: 1

Post axios request in Vue2 callback isn't working correctly

In my Vue2 application I am preforming a POST request with axios:

window.axios.post(`/clients/${this.getClientId}/connection`, {
                    clientType: newClientType,
                    url: this.client.url,
                    username: this.client.username,
                    password: this.client.password
                }).then((success)=>{

                console.log(success);

                },(error)=>{

                console.log(error);

                })

If this gets a 400 or 409(Any error responses) response the console.log I get is just 'false', whereas I would normally get a proper response, Don't understand why this response is different?

Upvotes: 0

Views: 95

Answers (1)

Jan Ciołek
Jan Ciołek

Reputation: 1816

Try this,it is a syntax from the docs

window.axios.post(`/clients/${this.getClientId}/connection`, {
                    clientType: newClientType,
                    url: this.client.url,
                    username: this.client.username,
                    password: this.client.password
                }).then((success)=>{

                console.log(success);

                }.catch(function (error) {
                    console.log(error);
                 });

Upvotes: 1

Related Questions