Concorde documentation · same URL (interactive) · llms.txt

Concorde decorator — @put. Sends the value of a publisher as the body of a PUT request, to replace a resource, and stores the response in an ApiResult<T> property. It takes the same arguments, options and send(component) handle Doc ID: docs/decorators/put. Keywords: Concorde, supersoniks, docs/decorators/put, put, @put, decorator, PUT, ApiResult, send(component), ${passengerId}, send, endpoint, Endpoint, bodyKey, DataProviderKey, configurationKey. URL: https://concorde.supersoniks.org/docs/decorators/put.

@put

Sends the value of a publisher as the body of a PUT request, to replace a resource, and stores the response in an ApiResult<T> property. It takes the same arguments, options and send(component) handle as @post; only the HTTP method differs.

Import

import { put, type ApiResult } from "@supersoniks/concorde/decorators";
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";

Basic usage

The full passenger record is sent on connect and after each body mutation. Placeholders such as ${passengerId} are resolved on the host component.

type Passenger = { name: string; flight: string; seat: string };

const passengerKey = new DataProviderKey&lt;Passenger&gt;("passengerForm");
const savePassenger = put(
  new Endpoint&lt;Passenger, { passengerId: string }&gt;("passengers/${passengerId}"),
  passengerKey,
  { autoPostOnBodyMutation: false },
);

@property() passengerId = "ada-lindqvist";

@savePassenger
@state()
payload?: ApiResult&lt;Passenger&gt;;

async save() {
  await savePassenger.send(this);
}

Triggers, the send method decorator and every option are described on @post.

API reference

Argument Type Description
endpoint Endpoint<T> Resource path and response type
bodyKey DataProviderKey<B> Publisher read as the full replacement body
configurationKey DataProviderKey<APIConfiguration> (optional) API configuration publisher. Default: HTML scope
options PutOptions Same as @post options