counters.get(name, [counterFile]) Last updated: 10. Dec 2024
API only function
Retrieves the current numerical value of a named counter, allowing you to monitor and track the state of various counters in your application.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the counter to retrieve. |
counterFile (optional) | string | Absolute file path to counter file. Default is "#/counters.json" if not specified. |
Returns
number
Example
Data
Returns the current value of the specified counter as a number.
Code example (JS)
JS is normal JavaScript either running in the browser or on the Docly™ server.// Get the current value of the 'pageViews' counter
let currentPageViews = counter.get('pageViews');
console.log('Current page views:', currentPageViews);