Pages

AgilityFetch.Client. Pages

Agility Fetch API JS SDK for retrieving pages from the Agility CMS

Source:

Methods

(static) getPage(requestParams) → {Promise.<AgilityFetch.Types.Page>}

Gets the details of a page by its Page ID.

Source:
Parameters:
Name Type Description
requestParams Object

The parameters for the API request.

Name Type Attributes Description
pageID number

The unique page ID of the page you wish to retrieve in the current language.

languageCode string

The language code of the content you want to retrieve.

expandAllContentLinks boolean <optional>

Whether or not to expand entire linked content references, includings lists and items that are rendered in the CMS as Grid or Link. Default is false

contentLinkDepth number <optional>

The depth, representing the levels in which you want linked content auto-resolved. Default is 2.

Returns:
Type:
Promise.<AgilityFetch.Types.Page>
  • Returns a page item object.
Example
import agility from '@agility/content-fetch'

const api = agility.getApi({
  guid: 'ade6cf3c',
  apiKey: 'defaultlive.201ffdd0841cacad5bb647e76547e918b0c9ecdb8b5ddb3cf92e9a79b03623cb',
});

api.getPage({
    pageID: 1,
    languageCode: 'en-us'
})
.then(function(page) {
    console.log(page);
})
.catch(function(error) {
    console.log(error);
});

(static) getSitemapFlat(requestParams) → {Promise.<AgilityFetch.Types.SitemapFlat>}

The sitemap, returned in a flat list, where the dictionary key is the page path. This method is ideal for page routing.

Source:
Parameters:
Name Type Description
requestParams Object

The parameters for the API request.

Name Type Description
channelName number

The reference name of the digital channel of the sitemap to return. If you only have one channel, your channel reference name is likely website.

languageCode string

The language code of the content you want to retrieve.

Returns:
Type:
Promise.<AgilityFetch.Types.SitemapFlat>
  • The sitemap response in a flat format.
Example
import agility from '@agility/content-fetch'

const api = agility.getApi({
  guid: 'ade6cf3c',
  apiKey: 'defaultlive.201ffdd0841cacad5bb647e76547e918b0c9ecdb8b5ddb3cf92e9a79b03623cb',
});

api.getSitemapFlat({
     channelName: 'website',
     languageCode: 'en-us'
})
.then(function(sitemap) {
     console.log(sitemap);
})
.catch(function(error) {
     console.log(error);
});

(static) getSitemapNested(requestParams) → {Promise.<AgilityFetch.Types.SitemapNested>}

Gets the sitemap as an array in a nested format, ideal for generating menus.

Source:
Parameters:
Name Type Description
requestParams Object

The parameters for the API request.

Name Type Description
channelName number

The reference name of the digital channel of the sitemap to return. If you only have one channel, your channel reference name is likely website.

languageCode string

The language code of the content you want to retrieve.

Returns:
Type:
Promise.<AgilityFetch.Types.SitemapNested>
  • The array of sitemap items returned.
Example
import agility from '@agility/content-fetch'

const api = agility.getApi({
  guid: 'ade6cf3c',
  apiKey: 'defaultlive.201ffdd0841cacad5bb647e76547e918b0c9ecdb8b5ddb3cf92e9a79b03623cb',
});

api.getSitemapNested({
     channelName: 'website',
     languageCode: 'en-us'
})
.then(function(sitemap) {
     console.log(sitemap);
})
.catch(function(error) {
     console.log(error);
});

(static) getUrlRedirections(requestParams) → {Promise.<AgilityFetch.Types.Gallery>}

Gets the details of a gallery by their Gallery ID.

Source:
Parameters:
Name Type Description
requestParams Object

The parameters for the API request.

Name Type Attributes Description
lastAccessDate Date <optional>

A Date object representing the last access date and time for the URL Redirections list. This value should be pulled from a previous request.

Returns:
Type:
Promise.<AgilityFetch.Types.Gallery>
  • Returns a gallery object.
Example
import agility from '@agility/content-fetch'

const api = agility.getApi({
  guid: 'ade6cf3c',
  apiKey: 'defaultlive.201ffdd0841cacad5bb647e76547e918b0c9ecdb8b5ddb3cf92e9a79b03623cb',
});

let dateObj = null;

api.getUrlRedirections({
    lastAccessDate: dateObj
})
.then(function({urlRedirections, lastAccessDate}) {
    console.log(urlRedirections.length, lastAccessDate);
})
.catch(function(error) {
    console.log(error);
});