Home > @vsf-enterprise/bigcommerce-theme > UseCategoryInterface > loadCategoryTreeList

# UseCategoryInterface.loadCategoryTreeList() method

Loads the category treee.

Signature:

loadCategoryTreeList(): Promise<void>;

Returns:

Promise<void>

# Remarks

Fetches category tree list from the API and stores it in categoryTreeStore.

# Example

Loading a category tree for current storefront.

import { defineComponent, useAsync } from '@nuxtjs/composition-api';
import { useCategory } from '~/composables';
import { useCategoryTreeStore } from '~/stores';

export default defineComponent({
  setup() {
    const categoryTreeStore = useCategoryTreeStore();
    const { loadCategoryTreeList } = useCategory();

    useAsync(async () => {
      await loadCategoryTreeList();
    });

    const navigation = computed(() =>
      categoryTreeStore.listOfRootBranches.map((rootLevel) => ({
        key: rootLevel.id,
        label: rootLevel.name,
        slug: rootLevel.url
      }))
    );

    return { navigation };
  }
});