onListRevisions
Revision listing handler
This example demonstrates how the onListRevisions 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.
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);
}
};