Google Sheets API v4 Node callback

I can’t seem to separate out an array of data from Google Sheets API. It would be ideal to have the returned Sheet in an array outside of the callback function. Other people talk about how easy this is, but I fail at it. See this for reference: https://developers.google.com/sheets/api/quickstart/nodejs

Don’t know about node but if you want to keep it simple you can just access the plain json file (all google docs generate an xml file and json file as standard).

Example
https://spreadsheets.google.com/feeds/list/1oGa2tdQJzsv6_g7uNHKL98VC8ReEIeo5HvOFujVTGuA/od6/public/values?alt=json

var spreadsheetID = "1oGa2tdQJzsv6_g7uNHKL98VC8ReEIeo5HvOFujVTGuA";


 var url = "https://spreadsheets.google.com/feeds/list/"+spreadsheetID+"/od6/public/values?alt=json";
 
 $.getJSON(url, function(data) {

  var entry = data.feed.entry;
 
 if(data.feed.entry[0]['gsx$show']['$t'] =="show"){
$('.results-gt-2').append("<div class='results-gt-inner-2 lp_toplinks'></div>");

	$('.results-gt-inner-2').append("<span class='boldred'>HOT TOPICS: </span>");
	
	
     $(entry).each(function(){
		$('.results-gt-inner-2').append('<span><a href="'+this.gsx$linkurl.$t+'" target="' + this.gsx$target.$t + '"> '+this.gsx$linktext.$t+'</a></span><span class="seperator"> | </span>');
  });
    	  
} else {
console.log("Results are hidden");
 
}
 
 });

It is most likely not what you wanted but i find it cool stumbling across someone else who is using google docs in interesting ways :smiley:

1 Like

I think this relies on the spreadsheet being public/published. And in my case it is “private” information.

I also love your Invader Zim avatar.

Yeah, needs to be publicly viewable

…One day the stupid human meatbags will recognize Zim’s greatness and it will get another series

Its bizarre how something as simple as running a site widget from a google doc datasource blew away some of the people in my company.