Agility Fetch API JS SDK for retrieving content from the Agility CMS
- Source:
Methods
(static) getContentItem(requestParams) → {Promise.<AgilityFetch.Types.ContentItem>}
Gets the details of a content item by their Content ID.
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
requestParams |
Object
|
The paramters for the API request.
|
Example
import agility from '@agility/content-fetch'
const api = agility.getApi({
guid: 'ade6cf3c',
apiKey: 'defaultlive.201ffdd0841cacad5bb647e76547e918b0c9ecdb8b5ddb3cf92e9a79b03623cb',
});
api.getContentItem({
contentID: 22,
languageCode: 'en-us'
})
.then(function(contentItem) {
console.log(contentItem);
})
.catch(function(error) {
console.log(error);
});
(static) getContentList(requestParams) → {Promise.<AgilityFetch.Types.ContentList>}
Retrieves a list of content items by reference name.
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
requestParams |
Object
|
The parameters for the API request.
|
Example
import agility from '@agility/content-fetch'
const api = agility.getApi({
guid: 'ade6cf3c',
apiKey: 'defaultlive.201ffdd0841cacad5bb647e76547e918b0c9ecdb8b5ddb3cf92e9a79b03623cb',
});
api.getContentList({
referenceName: 'posts',
languageCode: 'en-us',
take: 50,
skip: 0,
sort: 'properties.modified',
direction: api.types.SortDirections.ASC
})
.then(function(contentList) {
console.log(contentList);
})
.catch(function(error) {
console.log(error);
});
api.getContentList({
referenceName: 'posts',
languageCode: 'en-us',
take: 50,
skip: 0,
filters: [
{property: 'fields.title', operator: api.types.FilterOperators.EQUAL_TO, value: '"How this site works"'},
{property: 'fields.details', operator: api.types.FilterOperators.LIKE, value: '"Lorem ipsum dolar"'}
],
filtersLogicOperator: api.types.FilterLogicOperators.OR
})
.then(function(contentList) {
console.log(contentList);
})
.catch(function(error) {
console.log(error);
});