I am using push() method to add data to an object and receiving an Error:
Uncaught (in promise) TypeError: this.message.push is not a function
Some data is received from an API call, which is to be added to the object.
var price = new Vue({
delimiters: ["[[","]]"],
el: '#app',
data: {
message: {}
},
mounted () {
{% for i in arr %}
axios
.get('https:apicall/symbol={{ x }}')
.then(response => (this.message.push({name : response.data.price , cost: response.data.price.regularMarketPrice.fmt}))
{% endfor %}
}
})
However when I changed:
message: []
and
.then(response => (this.message.push(response.data.price))
it worked fine.
I am using Vue in Django framework and am new to Vue.js