Sync

AgilityFetch.Client. Sync

Agility Fetch API JS SDK for synchronizing content from Agility CMS

Source:

Methods

(static) getSyncContent(requestParams) → {Promise.<AgilityFetch.Types.SyncContent>}

Retrieves a list of content items that need to be synced based on the provided sync content items token, and returns the next sync token.

Source:
Parameters:
Name Type Description
requestParams Object

The paramters for the API request.

Name Type Attributes Description
syncToken number

The sync token provided in the response to a previous sync API call. To start a new sync, use the value of '0'.

languageCode string

The language code of the content you want to retrieve.

pageSize number <optional>

The number of items to return back with each call. Default is 500.

Returns:
Type:
Promise.<AgilityFetch.Types.SyncContent>
  • Returns a list of content item objects.
Example
import agility from '@agility/content-fetch'

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

api.getSyncContent({
     syncToken: '0', //to start a new sync
     languageCode: 'en-us',
     pageSize: 500
})
.then(function(contentList) {
     console.log(contentList.items);

     //the next sync token to use, continue to call this method (loop) until no sync token is provided in the response. This indicates your are up to date.
     console.log(contentList.syncToken); 
})
.catch(function(error) {
     console.log(error);
});

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

Retrieves a list of pages that need to be synced based on the provided sync pages token, and returns the next sync token.

Source:
Parameters:
Name Type Description
requestParams Object

The paramters for the API request.

Name Type Attributes Description
syncToken number

The sync token provided in the response to a previous sync API call. To start a new sync, use the value of '0'.

languageCode string

The language code of the content you want to retrieve.

pageSize number <optional>

The number of items to return back with each call. Default is 1000.

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

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

api.getSyncPages({
     syncToken: '0', //to start a new sync
     languageCode: 'en-us',
     pageSize: 500
})
.then(function(pages) {
     console.log(pages.items);

     //the next sync token to use, continue to call this method (loop) until no sync token is provided in the response. This indicates your are up to date.
     console.log(pages.syncToken); 
})
.catch(function(error) {
     console.log(error);
});