# @get

Loads data through [`API.getDetailed`](../../core/utils/api.ts). The decorated property is **`ApiGetResult<T> | null`**: `request`, `response` (or `null` for `dataProvider(...)` resolution without HTTP), and typed `result`.

Pass an [`Endpoint<T>`](#docs/_misc/endpoint.md/endpoint) as the first argument. Import `get` and `ApiGetResult` from `@supersoniks/concorde/decorators`, and `Endpoint` from `@supersoniks/concorde/utils/endpoint`.

## Configuration

- **Default:** `HTML.getApiConfiguration(host)` (ancestor `serviceURL`, etc.).
- **Second argument:** `DataProviderKey<APIConfiguration>` — config is read from the publisher at the resolved path; internal mutations trigger another GET.

## When the GET runs again

- A referenced Lit property changes (endpoint path and/or config key contains `${...}`).
- `set` on the active configuration publisher (`onInternalMutation`).

## Import

<sonic-code language="typescript">
  <template>
import { get, type ApiGetResult } from "@supersoniks/concorde/decorators";
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
  </template>
</sonic-code>

## Minimal example

Same demo service as [`sonic-queue`](../../core/components/functional/queue/queue.demo.ts) (`geo.api.gouv.fr`). Publisher setup lives in `decorators-demo-geo.ts` and `decorators-demo-subscribe-publish-get-demos.ts`.

<sonic-code language="typescript">
  <template>
@get(new Endpoint<User>("users/${userId}"))
@state()
payload: ApiGetResult<User> | null = null;
  </template>
</sonic-code>

## Live demos

<sonic-code>
  <template>
    <demo-api-get></demo-api-get>
  </template>
</sonic-code>

Dynamic config and endpoint path (`demo-api-get-configuration-key` in doc sources):

<sonic-code>
  <template>
    <demo-api-get-configuration-key></demo-api-get-configuration-key>
  </template>
</sonic-code>

Scoped `@get` with `@publish` / `@subscribe` on the payload (see [@publish](#docs/_decorators/publish.md/publish) and [@subscribe](#docs/_decorators/subscribe.md/subscribe)) — wrap under an ancestor with `serviceURL="https://geo.api.gouv.fr/"`:

<sonic-code>
  <template>
<div serviceURL="https://geo.api.gouv.fr/">
  <demo-api-get-publish-subscribe></demo-api-get-publish-subscribe>
</div>
  </template>
</sonic-code>

Stale responses are ignored if the path or generation changed before the request finished.
