antd-crud-table API
    Preparing search index...

    Class RestDataSource<T, K>

    A source over a REST API.

    URL and payload construction live in protected methods rather than inline, so an API that does not match the default dialect is a small subclass instead of a full reimplementation of the strategy.

    Type Parameters

    • T extends object
    • K extends keyof T

    Implements

    Index
    baseUrl: string

    Prefixed to every request path, exactly once.

    configureRequest?: (
        context: RestRequestContext<T, K>,
    ) => RestRequestOverrides | Promise<RestRequestOverrides>

    Resolves per-request adjustments at call time.

    endpoints: RestEndpoints

    Resolved per-operation paths.

    headers: Readonly<Record<string, string>>

    Headers sent with every request.

    init: Omit<RequestInit, "method" | "body" | "headers">

    Passed through to fetch on every request.

    methods: RestMethods

    Resolved HTTP verbs.

    paramNames: RestParamNames

    Resolved query-parameter names.

    parseRecord?: (payload: unknown, context: RestRequestContext<T, K>) => T

    Maps a create or update response onto the stored record.

    parseResponse?: (payload: unknown) => CrudPage<T>

    Maps a list payload onto a page, when the API wraps its results.

    query: Readonly<Record<string, RestQueryValue>>

    Appended to every request's query string.

    serializeRequest: (
        draft: CrudDraft<T>,
        context: RestRequestContext<T, K>,
    ) => unknown

    Maps a draft onto the request body.

    • Path addressing a single record. Override for ?id= style APIs.

      Parameters

      • endpoint: string
      • id: T[K]

      Returns string

    • Single point where baseUrl, headers and error handling are applied.

      Every request goes through here so baseUrl is prefixed exactly once - building a full URL earlier and prefixing again is how it ended up duplicated for relative bases.

      Parameters

      Returns Promise<unknown>

    • Encode filters as query parameters.

      Each filter is sent under its own field name, which suits an API that filters per column. An API with a single search parameter - ?q= is the common shape - wants them combined instead, so this is a seam rather than inline, matching serializeSort.

      Parameters

      • filters: CrudFilters<T> | undefined
      • params: URLSearchParams

      Returns void

    • Encode sort instructions as query parameters.

      Only the first instruction is sent: sortBy/sortOrder is a single-sort shape, and inventing a multi-sort encoding would guess at a convention the server may not share. Override to support one.

      Parameters

      • sort: readonly CrudSort<T>[] | undefined
      • params: URLSearchParams

      Returns void

    • Interpret a list payload.

      Without a parseResponse, accepts either a bare array or the { data, total } shape the previous implementation assumed.

      Parameters

      • payload: unknown

      Returns CrudPage<T>