Search code examples
spartacus-storefront

Page service in spartacus?


If CMSService.getComponentData() is to get the component data (Component Controller in swagger).

May I know what service is needed to get page data with list of CMS content slots (Page Controller in swagger)?


Solution

  • The CmsService from the core lib provides a method to get the current page, based on the current route:

    CmsService.getCurrentPage()

    This returns an observable with a Page.

    Under the hood, the page is selected based on the page context, which has a page type (product, category, content) and id (product code, category code, search query).