Skip to main content
Browse Documentation

Components

Created by Alex Pop, last modified by Simon Horan on 22 Jan 2020

A component determines a reusable schema added to content types which entries are then created from. Components contain a list of fields just like content types, and allow for a standardized schema for modelling content.Find out more about components on ZenHub

Get a component

Gets an existing component by the component id or by passing a ComponentGetOptions object as an argument.

get(idOrOptions: string | ComponentGetOptions): Promise<Component>

Returns

A Promise that will resolve with a Component object.

Example

```js
client.components.get('address')
.then(result => {
console.log('API call result: ', result);
})
.catch(error => {
console.log('API call fetch error: ', error);
});

client.components.get({
id: 'address',
versionStatus: 'published'
})
.then(result => {
console.log('API call result: ', result);
})
.catch(error => {
console.log('API call fetch error: ', error);
});

client.components.get({
id: 'address',
version: '1.2'
})
.then(result => {
console.log('API call result: ', result);
})
.catch(error => {
console.log('API call fetch error: ', error);
});```