onListDimensions
Dimension listing handler
This example demonstrates how the onListDimensions callback
sends a request using the Fetch API to retrieve dimensions for a dimension group revision. Once the request completes, the
result and returned dimensions are provided to the widget through the
onResponse
callback.
Dimension listing handler
onListDimensions = async function(group: DIQ_DimensionGroupRevision, onResponse: (result: DIQ_Result, dimensions: Array<DIQ_Dimension> | null) => void) {
try {
const res = await fetch(`/api/dimension-groups/${group.key}/dimensions`);
if (!res.ok) {
throw new Error(`HTTP ${res.status}`);
}
const dimensions = await res.json();
onResponse(
{ ok: true },
dimensions
);
} catch (err) {
onResponse(
{
ok: false,
message: err.message || "Failed to fetch dimensions"
},
null
);
}
};