0.2.14 • Published 3 years ago
@vtex/client-cms v0.2.14
client-cms
This package is responsible for fetching data from VTEX CMS.
Installation
To install @vtex/client-cms in your project, just run:
npm instal @vtex/client-cmsClient Instance
To create a new ClientCMS instance you should use the ClientCMS class:
const client = new ClientCMS({
tenant: '',
builder: '',
workspace: ''
});Where tenant is your store's account name and workspace is the VTEX IO workspace being used. Usually you won't to set this option, being master the default. You can use builder to specify a different source of data on the CMS, using 'faststore' as default.
Querying data
With the client instance you should use the main three methods to query data:
To gets ids from all Content Types.
const contentTypeIds = await client.getAllContentTypeIds();To gets data from all pages of a given Content Type.
const paginatedCMSPages = await client.getCMSPagesByContentType(
'contentTypeId',
{
page: 1,
perPage: 3,
}
);To gets all data from a given page.
const CMSPage = await client.getCMSPage({
contentType: '',
documentId: '',
versionId: '',
});