I have a javascript function that grabs the 10 last retrieved closed websites with a chrome api, and it then simplifies the list into an array of objects with the title, and url of each website. Vue is displaying this array of objects fine when I initialize it myself, however it does not work when trying to use the function to get the array. Why isn't Vue showing anything?
As previously said, I have tried initializing the array of objects myself and have had no issues with displaying it like that. However setting it up so that before the Vue is rendered, the function to generate the array is run will still not solve the issue.
var gotLast10;
function getLast10() {
chrome.sessions.getRecentlyClosed({}, function (results){
if (results.length > 10){
results = results.slice(0, 10);
var tempLast10 = [];
results.forEach(
function(eachSite) {
var tempObject = { TITLE: eachSite.tab.title, URL: eachSite.tab.url}
tempLast10.push(tempObject);
gotLast10 = tempLast10;
}
);
}
});
console.log(gotLast10);
}
$(document).ready(
function() {
getLast10();
vm = new Vue({
el: '#app',
data: {
gotLast10: gotLast10,
}
});
}
);
<div id=app>
{{ gotLast10 }}
</div>
I expected Vue to display the object normally, but it just ends up displaying nothing