[Vuejs]-POST data sent from VueJs to server is in strange format

0๐Ÿ‘

โœ…

I have found answer on Github

Yes, StringClient uses the application/x-www-form-urlencoded format by default while axios uses application/json by default (when data is an Object).

So current implementation looks like this

var params = new URLSearchParams();
params.append('name', this.name);
params.append('email', this.email);
params.append('subject', this.subject);
params.append('message', this.message);
this.$http.post(this.$apiUrl + `rest/api/public/Contact/Contact`, params, {
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
    }
})

Leave a comment