# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://oten.gitbook.io/oten-trust-support/documentation/api-reference/code-samples/browser-javascript.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
