edit: shoot this is probably a referencing object problem. sorry can’t seem to delete it!
Hi total beginner here, sorry if this is obvious. Wondering if there’s something different about scope in glitch.
Using tabletop.js to get data from a sheet and it works just fine. Except I can’t seem to get the data outside the getSheet function. I declare a global variable at the top, googleSheet, but when I try to console log it out it’s undefined. Am I missing something obvious?
var googleSheet;
var docURL = 'https://docs.google.com/spreadsheets/d/1f9YbgTnni508w6cYZnfjwSuG3idPBmeQSVG-C9916Oo/edit';
//init tabletop and put googlesheet into data var
function init() {
Tabletop.init( { key: docURL,
callback: getSheet,
simpleSheet: true } )
};
function getSheet(data, tabletop) {
googleSheet = JSON.parse(JSON.stringify(data)); //copy the data objects into googleSheet var
console.log('googleSheet working great the inside the function ', googleSheet);
}
window.addEventListener('DOMContentLoaded', init)
console.log('googleSheet not working outside the function ', googleSheet)
tabletop is initializing fine and all that. I was following along with this coding train tutorial, his code is set up same as mine (i think) and works: