Utilizing vuejs
in combination with axios
and a Django
server presents a challenge. The server requires parameters to be passed as travelers
, but when using axios
to send this data, it appends [] at the end resulting in travelers[]
.
Is there a way to prevent this behavior?
Here is an example snippet of the code:
Within the VueJS
instance, we have:
data = {
filter:{
travelers:[],
order:...,
...
The travelers
variable can either be an array of ids or an empty array. Even though it is defined as travelers
, when sent via axios
, it adds [] automatically.
This part of the code generates the issue:
loadOrders: function () {
axios.get(this.list_orders_url, {
params: this.filter
}).then(function (response) {
app.orders = response.data;
}).catch(function (error) {
console.log(error); // todo
})
},
Effectively, it results in travelers[]=1&travelers[]=2
being included in the query string.