# evaluate

Learn how to evaluate a CQL query using a standalone function.

This method evaluates a [CQL query](/reference/cql) in real-time and returns the result.

For more information, see [Query evaluation](/reference/sdk/javascript/query-evaluation).

## Signature

This method has the following signature:

```ts
croct.evaluate<T extends JsonValue>(query: string, options: EvaluationOptions): Promise<T>;
```

The return is a `Promise` that resolves to the evaluation result.

## Example

Here is a basic example of how to use this method:

```ts
import croct from '@croct/plug';

croct.evaluate("user's interests").then(console.log);
```

For more examples, see the [Query evaluation](/reference/sdk/javascript/query-evaluation) reference.

## Parameters

The following list describes the supported parameters:

- `query`: `string`

  The [CQL query](/reference/cql) to evaluate, with a maximum length of 500 characters.

- `options`: `object` (optional)

  The evaluation options.

  - `timeout`: `number` (optional)

    The maximum fetch time in milliseconds.

    > **Good to know**
    >
    > You can set a [default timeout](plug#configuration-defaultfetchtimeout-prop) for your application during SDK initialization, eliminating the need to specify it each time.

    Once reached, the SDK will abort the request and reject the promise with a timeout error.

  - `attributes`: `object` (optional)

    The map of attributes to inject in the evaluation context.

    The attributes can be referenced in audience conditions using the [`context`](/reference/cql/context#evaluation) variable. For example, suppose you pass the following attributes:

    ```json
    {cities: ["New York", "San Francisco"]}
    ```

    You can then reference them in queries like:

    ```cql
    context's cities include location's cityName
    ```

    For more information, see [Context variables](../../content-rendering#context-variables).

    The following restrictions apply to the attributes:

    - Up to 30 entries and 5 levels deep
    - Keys can be either numbers or non-empty strings with a maximum length of 50 characters
    - Values can be null, numbers, booleans, strings (up to 50 characters), or nested maps
    - Nested maps follow the same constraints for keys and values
