onDimensionGroupFolderNew
Dimension group folder creation handler
This example demonstrates how the onDimensionGroupFolderNew callback
sends a request using the Fetch API to create a new dimension group folder. Once the request completes, the
result is returned to the widget through the
onResponse
callback.
Dimension group folder creation handler
onDimensionGroupFolderNew = async function(folder: DIQ_DimensionGroupFolder, onResponse: (result: DIQ_Result) => void) {
try {
const res = await fetch("/api/dimension-group-folders", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(folder)
});
if (!res.ok) {
throw new Error(`HTTP ${res.status}`);
}
await res.json();
onResponse({ ok: true });
} catch (err) {
onResponse({
ok: false,
message: err.message || "Failed to create folder"
});
}
};