Skip to content

Instantly share code, notes, and snippets.

@ademilter
Last active March 20, 2018 10:55
Show Gist options
  • Select an option

  • Save ademilter/d464b7c378b61cc38b8d3872f6a33b3f to your computer and use it in GitHub Desktop.

Select an option

Save ademilter/d464b7c378b61cc38b8d3872f6a33b3f to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/wacibirore
var Categories = {};
fetch('http://api.bigchefs.protelworks.com/menu/items/').then(function (response) {
return response.json();
}).then(function (data) {
console.log(data);
data.menu_items.forEach(function (obj) {
if (!_.has(Categories, obj.categories)) {
_.set(Categories, obj.categories.join(".") + '.items', []);
}
var items = _.get(Categories, obj.categories.join(".") + '.items');
items.push(obj);
});
console.log(Categories);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment