onProjectClose
Project close handler
This example demonstrates how the onProjectClose callback
sends a request using the Fetch API to close the current project. Once the request completes, the
result is returned to the widget through the
onResponse
callback.
Project close handler
onProjectClose = async function(onResponse: (result: DIQ_Result) => void) {
try {
const res = await fetch("/api/project/close", {
method: "POST"
});
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 close project"
});
}
};