$(function() {
$.get("https://spreadsheets.google.com/feeds/list/1VC633BXpMElJjRWvIRuZIP7UrEhuw6BdscnrV2heox0/1/public/full?alt=json", function(data) {
var entry = data.feed.entry;
var getKeys = Object.keys(entry[0]).slice(6);
arr = getKeys.map(title => {
return entry.map((el) => {
return el[title].$t;
}).filter((el) => {
return el.trim();
});
});
console.log(getKeys);
console.log(arr);
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Code above will return data from google sheet into array of arrays.
I've been stuck on assigning the value from getKeys to each arr group to return a new arr value:
var arr = [
gsx$fruits = ["apple", "banana"],
gsx$animals = ["monkey", "dog", "cat", "bear"],
gsx$numbers = ["one", "two", "three", "four"]
]
...this way I can be able to access a specific group not just by index position. Thanks for your help!
{ fruits: [...], animals: [...], numbers: [...]}