Skip to content

@salesforce/b2c-tooling-sdk / operations/content / fetchContentLibrary

Function: fetchContentLibrary() ​

fetchContentLibrary(instance, libraryId, options): Promise<FetchContentLibraryResult>

Defined in: packages/b2c-tooling-sdk/src/operations/content/export.ts:47

Fetch and parse a content library from an instance (or local file).

Returns the parsed Library and optionally the raw archive data. No filesystem side effects.

Parameters ​

instance ​

B2CInstance

B2C instance to fetch from

libraryId ​

string

Library ID (or site ID if isSiteLibrary is true)

options ​

FetchContentLibraryOptions = {}

Fetch options

Returns ​

Promise<FetchContentLibraryResult>

Parsed library and optional archive data

Example ​

typescript
// Fetch from instance
const { library } = await fetchContentLibrary(instance, 'SharedLibrary');

// Filter and traverse
library.filter(n => n.id === 'homepage');
const xml = await library.toXMLString({ traverseHidden: false });

// Use local file instead
const { library } = await fetchContentLibrary(instance, 'SharedLibrary', {
  libraryFile: './library.xml'
});

Released under the Apache-2.0 License.