I am trying to use setState to load data into my template page on pageInit, but i get the “Cannot read property ‘XXX’ of undefined” error triggered by the template {{mydatathatisntloadedyet}} before the page can run the pageInit to get the data. i know about the async route method that can load context data before the page transitions but i want to do the ajax on the component page with pageInit after the transition. Is there a way for me to have the template load the html without throwing errors so it can update the template after the setState?
return {
data: function () {
return {
title: 'Welcome',
}
},
methods: {
},
on: {
pageInit: function(){
app.request.json('URL', function (c_data) {
self.$setState({
view_data: c_data,
});
});
}
}
}