Skip to main content

Controller API

Use initializeSpaazaElements() to set up the controller and mount components. Returns Promise<SpaazaController>.

InitOptions

PropertyTypeRequiredDescription
targetstringYesCSS selector (e.g., '#spaaza-elements')
configSpaazaConfigYesAPI and authentication configuration
pageNamestringNoPage name to load (default: "home")
campaignIdnumberNoCampaign ID. Activates the detail view.
voucherIdnumberNoVoucher ID. Activates the detail view.
businessIdnumberNoFilter page content by store. From user.home_store.home_store_id.
componentBaseUrlstringNoBase URL for web component bundles
customZonesCustomZonesOptionsNoCustom zones for voucher and membercard display. See Custom Zones.
handlerOverridesobjectNoDisable automatic handling for specific operations. See Handler Overrides.

SpaazaConfig

PropertyTypeRequiredDescription
originstringYesAPI origin. Set to https://{API hostname} for your environment. Spaaza provides a different hostname per environment.
auth.sessionKeystringYesSession key from login
auth.userIDstringYesUser ID from login
auth.myPriceAppHoststringYesYour Spaaza app hostname (e.g., {MyPrice App hostname})

Controller Methods

The controller returned by initializeSpaazaElements() provides:

MethodDescription
parseImageLink(imageLink)Parse image_link string. See parseImageLink() for the full return-value table.
refresh()Refresh current view (re-fetches data)
const controller = await initializeSpaazaElements({ ... });

// Refresh current view
await controller.refresh();