Skip to main content

onListDrawingLayouts

Last updated 8/03/2026

Drawing layout listing handler

This example demonstrates how the

callback sends a request using the Fetch API to retrieve layouts for a drawing. Once the request completes, the result and returned layouts are provided to the widget through the

onResponse
callback.

TypeScript
Drawing layout listing handler
onListDrawingLayouts = async function (drawing: DIQ_DrawingRevision, onResponse: (result: DIQ_Result, layouts: Array<DIQ_Layout> | null ) => void) {
try {
const res = await fetch(`/api/drawings/${drawing.key}/layouts`, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
});

if (!res.ok) {
throw new Error(`HTTP ${res.status}`);
}

const layouts: DIQ_Layout[] = await res.json();

onResponse({ ok: true }, layouts);

} catch (err) {
onResponse({
ok: false,
message: err.message || "Failed to fetch layouts"
}, null);
}
};