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