// Wait for a specific navigation event
const response = await fetch(
`https://api.bctrl.ai/v1/sessions/${sessionId}/events/wait`,
{
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
eventTypes: ['page.navigated'],
timeoutMs: 10000,
}),
}
);
const { event, timedOut } = await response.json();