I encountered an issue while trying to use the push() method to add data to an object:
Uncaught (in promise) TypeError: this.message.push is not a function
The scenario involves receiving data from an API call and needing to append it to an 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 %}
}
})
After making the following changes:
message: []
and
.then(response => (this.message.push(response.data.price))
The problem was resolved successfully. This project involves using Vue within the Django framework, and as a beginner to Vue.js, I am learning along the way.