Skip to main content

onListRevisions

Last updated 8/03/2026

Revision listing handler

This example demonstrates how the

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

onResponse
callback.

TypeScript
Revision listing handler
onListRevisions = async function (project: DIQ_Project, onResponse: (result: DIQ_Result, revisions: Array<DIQ_Revision> | null ) => void) {
try {
const res = await fetch(`/api/projects/${project.key}/revisions`, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
});

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

const revisions: DIQ_Revision[] = await res.json();

// Successful response
onResponse({ ok: true }, revisions);

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