Hi I am trying to add json data to an element. I get the data via a jsonp call to an external API. but somehow vue does not recognize that the variable is there. Since the app is in laravel I read on laracasts forum that the data and methods properties should be defined in components, but that does not also solve my problem. I am using vue.js2 and laravel 5.4
I get the following error:
app.js: [Vue warn]: Property or method "names" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
here is my code:
app.js
Vue.component('search',
{
template: '<div class="panel-heading" ></div>',
data: function(){
return {
names: []
}
},
methods: {
getData: function(){
var self = this;
// GET request
this.$http.jsonp(url,
{
jsonpCallback: "JSON_CALLBACK"
})
.then(
response=>{
this.names = response.body
})}
}
});
const app = new Vue({
el: '#search'
});
blade template
<div id='search'>
<search v-for='name in names'>
@{{name.label.eng}}
</search>
</div>