Skip to content

Instantly share code, notes, and snippets.

@stefanoverna
Created April 27, 2017 13:39
Show Gist options
  • Select an option

  • Save stefanoverna/f94da8669ad0a24c8006521741a9532e to your computer and use it in GitHub Desktop.

Select an option

Save stefanoverna/f94da8669ad0a24c8006521741a9532e to your computer and use it in GitHub Desktop.
var Dato = require('datocms-client');
var Loader = require('datocms-client/lib/local/Loader');
const client = new Dato.SiteClient('XXX');
const loader = new Loader(client);
loader.load().then(() => {
const dato = loader.itemsRepo;
// ok, now "dato" exposes everything contained in the space with a friendly API:
// you can use method chains to navigate deeply across your records’ relationships...
dato.blogPosts[0].authors[0].firstName;
// offer higher-level methods for specific fields...
dato.blogPosts[0].coverImage.url({ w: 800, h: 600, fm: 'jpg' })
// and pretty much everything that's covered in our documentation: https://docs.datocms.com/other/overview.html
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment