> For the complete documentation index, see [llms.txt](https://oten.gitbook.io/trust-support/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://oten.gitbook.io/trust-support/documentation/api-reference/code-samples/browser-javascript.md).

# Browser (JavaScript)

{% hint style="info" %}
**Important:** The native `EventSource` API does not support custom headers. To authenticate from the browser, you must either:

Proxy requests through your own backend that injects the `Authorization` header
{% endhint %}

Native EventSource (requires proxy or query-param auth)

{% code lineNumbers="true" %}

```
const eventSource = new EventSource(
  '/api/v1/scan-url?url=https://seranking.com&lang=en'
);

eventSource.addEventListener('progress', (e) => {
  const data = JSON.parse(e.data);
  console.log(`[${data.percent}%] ${data.current_task}`);
});

eventSource.addEventListener('result', (e) => {
  const data = JSON.parse(e.data);
  console.log('Result:', data);
  eventSource.close();
});

eventSource.addEventListener('error', (e) => {
  if (e.data) {
    const data = JSON.parse(e.data);
    console.error('Scan error:', data.error_message);
  }
  eventSource.close();
});

```

{% endcode %}
