onDimensionsDelete
Dimensions deletion handler
This example demonstrates how the onDimensionsDelete callback
sends a request using the Fetch API to delete dimensions. Once the request completes, the result is returned to the widget through the
onResponse
callback.
Dimensions deletion handler
const onDimensionsDelete = async function (dimensions: Array<DIQ_Dimension>, onResponse: (result: DIQ_Result) => void) {
try {
const res = await fetch("/api/dimensions", {
method: "DELETE",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ dimensions })
});
if (!res.ok) {
throw new Error(`HTTP ${res.status}`);
}
await res.json();
onResponse({ ok: true });
} catch (err: any) {
onResponse({
ok: false,
message: err.message || "Failed to delete dimensions"
});
}
};