Example code:
const { SiteClient } = require('datocms-client');
async function run() {
const client = new SiteClient('YOUR-API-TOKEN');
const itemTypes = await client.itemTypes.all();
itemTypes.forEach((itemType) => {
console.log(itemType);
});
}
run();
Returned output:
> node example.js
{
"id": "44",
"name": "Blog post",
"apiKey": "post",
"collectionAppearance": "compact",
"singleton": false,
"allLocalesRequired": false,
"sortable": true,
"modularBlock": false,
"draftModeActive": false,
"tree": false,
"orderingDirection": null,
"orderingMeta": "created_at",
"hasSingletonItem": false,
"hint": "Blog posts will be shown in our website under the Blog section",
"singletonItem": null,
"fields": [
"124"
],
"titleField": null,
"imagePreviewField": null,
"excerptField": null,
"orderingField": null,
"workflow": null
}