Skip to content

Use Cases

Fetch Navigation

api
  .fetchNavigation({ locale: 'de_DE' })
  .then((result) => console.log('Fetched Navigation: ', result))
  .catch((error) => console.error('Failed to fetch navigation', error));

Create Page

Product

api
  .createPage({
    fsPageTemplate: 'product', // (1)
    id: `Product Page`,        // (2)
    type: 'product',           // (3)
    displayNames: {
      EN: `Product Page EN`,   // (4)
      DE: `Product Page DE`,
    },
  })
  .then((isSuccess) => console.log('Create Product Page: ', isSuccess ? 'SUCCESSFUL' : 'FAILED'))
  .catch((error) => console.error('Failed to create product page', error));
  1. FirstSpirit page template uid
  2. ID from shop system
  3. Page type to create (product, category or content)
  4. Display names for various languages

Category

api
  .createPage({
    fsPageTemplate: 'category', // (1)
    id: `Category Page`,        // (2)
    type: 'category',           // (3)
    displayNames: {
      EN: `Category Page EN`,   // (4)
      DE: `Category Page DE`,
    },
  })
  .then((isSuccess) => console.log('Create Category Page: ', isSuccess ? 'SUCCESSFUL' : 'FAILED'))
  .catch((error) => console.error('Failed to create category page', error));
  1. FirstSpirit page template uid
  2. ID from shop system
  3. Page type to create (product, category or content)
  4. Display names for various languages

Content

api
  .createPage({
    fsPageTemplate: 'contentpage', // (1)
    id: `Content Page`,            // (2)
    type: 'content',               // (3)
    displayNames: {
      EN: `Content Page EN`,       // (4)
      DE: `Content Page DE`,
    },
  })
  .then((isSuccess) => console.log('Created Content Page: ', isSuccess ? 'SUCCESSFUL' : 'FAILED'))
  .catch((error) => console.error('Failed to create content page', error));
  1. FirstSpirit page template uid
  2. ID from shop system
  3. Page type to create (product, category or content)
  4. Display names for various languages

Find Page

api
  .findPage({
    locale: 'de_DE',
    id: `Content Page`, // (1)
    type: 'content',    // (2)
  })
  .then((pageResult) => console.log('Found Page: ', pageResult))
  .catch((error) => console.error('Failed to find page', error));
  1. ID from shop system
  2. Page type to fetch (product, category or content)

Create Section

api
  .findPage({ // (1)
    locale: 'de_DE',
    id: `Content Page`,     // (2)
    type: 'content',        // (3)
  })
  .then((pageResult) => {
    console.log('Found Page: ', pageResult);

    api
      .createSection({
        pageId: pageResult.items[0].previewId, // (4)
        slotName: 'content',                   // (5)
      })
      .then((isSuccess) => console.log('Create Section: ', isSuccess ? 'SUCCESSFUL' : 'FAILED'))
      .catch((error) => console.error('Failed to create section', error));

  })
  .catch((error) => console.error('Failed to find page', error));
  1. Find the page first to retrieve the preview ID
  2. ID from shop system
  3. Page type to create (product, category or content)
  4. Preview ID from FirstSpirit
  5. Name of the slot to create a section in

Last update: November 15, 2022