I'm trying to add items from a modified list of thumbs to a service worker storage cache by JSON import.
Everything's working as far as generating a correctly-formatted and complete array of thumbs to cache -- console.log(cacheArray) inside the for statement -- but I can't seem to get a final array out of the function -- console.log('updateCache: ' + cacheArray) returns a blank:
fetch('alldates.txt').then(function(response) { return response.text(); }).then(function(string) { var alldatesobj = JSON.parse(string); var cacheThumb; var thumbslist = Object.values(alldatesobj); var cacheArray = new Array(); function updateCache(cacheArray) { for(i = 1; i <= thumbslist.length; i++) { cacheThumb = thumbslist[i].replace('100315', '100315/thumbs'); cacheArray.push(cacheThumb); //console.log(cacheArray.slice(-1)[0]); //console.log(cacheArray); //^^^ array is correctly formed!!! } return cacheArray; } updateCache(console.log('updateCache: ' + cacheArray)); });