Skip to main content

onProjectOpen

Last updated 8/03/2026

Project open handler

This example demonstrates how the

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

onResponse
callback.

TypeScript
Project open handler
onProjectOpen = async function(onResponse: (result: DIQ_Result, project: DIQ_Project | null) => void) {
try {
const res = await fetch("/api/project/current");

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

const project = await res.json();

onResponse(
{ ok: true },
project
);

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