Home > widget-integration > CountdownTimerAPI > getTimer
CountdownTimerAPI.getTimer() method
Fetch the most relevant countdown timer for the current page context.
Resolves the page scope, builds query params (scope, country, shop, product), and calls GET /countdown-timer. The backend applies all filtering and returns at most one campaign.
Signature:
getTimer(): Promise<CountdownCampaign | null>;
Returns:
Promise<CountdownCampaign | null>
The active campaign for this page, or null if the page type is unsupported or no campaign matches the current context.
Exceptions
{Error} When the network request fails or the response cannot be parsed
Example
Override to add fallback logic:
window.boostWidgetIntegration.extend('CountdownTimerAPI', (CountdownTimerAPI) => {
return class CustomCountdownTimerAPI extends CountdownTimerAPI {
async getTimer() {
const campaign = await super.getTimer();
if (!campaign) return this.getFallbackCampaign();
return campaign;
}
};
});