UNPKG

@agility/content-fetch

Version:
43 lines (42 loc) 1.84 kB
import { ApiClientInstance } from '../types/Client'; /** * Gets the details of a content item by their Content ID. * @memberof AgilityFetch.Client.Content * @param {Object} requestParams - The paramters for the API request. * @param {number} requestParams.contentID - The contentID of the requested item in this language. * @param {string} requestParams.locale - The locale code of the content you want to retrieve. * @param {string} requestParams.languageCode DEPRECATED: Use locale instead - The language code of the content you want to retrieve. * @param {number} [requestParams.contentLinkDepth] - The depth, representing the levels in which you want linked content auto-resolved. Default is **1**. * @param {boolean} [requestParams.expandAllContentLinks] - 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** * @returns {Promise<AgilityFetch.Types.ContentItem>} - Returns a content item object. * @example * * import agility from '@agility/content-fetch' * * const api = agility.getApi({ * guid: 'ade6cf3c', * apiKey: 'defaultlive.201ffdd0841cacad5bb647e76547e918b0c9ecdb8b5ddb3cf92e9a79b03623cb', * }); * * api.getContentItem({ * contentID: 22, * locale: 'en-us' * }) * .then(function(contentItem) { * console.log(contentItem); * }) * .catch(function(error) { * console.log(error); * }); * */ import { ContentItem } from '../types/ContentItem'; export interface ContentItemRequestParams { contentID: number; locale?: string; languageCode?: string; contentLinkDepth?: number; expandAllContentLinks?: boolean; } declare function getContentItem<T>(this: ApiClientInstance, requestParams: ContentItemRequestParams): Promise<ContentItem<T>>; export default getContentItem;