AngularTS
    Preparing search index...

    Class RestService<T, ID>

    Typed REST resource client backed by RestBackend.

    A RestService is usually created by injecting $rest and calling it with a base URL, optional EntityClass, and optional backend request defaults.

    Type Parameters

    • T = unknown
    • ID = unknown
    Index

    Constructors

    • Type Parameters

      • T = unknown
      • ID = unknown

      Parameters

      • backend: RestBackend
      • baseUrl: string

        Base URL or RFC 6570 URI template for this resource.

      • OptionalentityClass: EntityClass<T>

        Optional mapper that converts raw JSON objects into entity instances.

      • options: RestOptions = {}

        Extra backend options merged into every request.

      Returns RestService<T, ID>

      Error when baseUrl is empty or not a string.

    Properties

    $nonscope: boolean = true

    Methods

    • Expand an RFC 6570 URI template with the provided parameters.

      Parameters

      • template: string

        URI template such as /api/{org}/repos/{repo}.

      • params: Record<string, unknown>

        Values used for URI template expansion.

      Returns string

      The expanded URL.

    • Create a resource using POST.

      Parameters

      • item: T

        Request body to create.

      Returns Promise<unknown>

      The server representation, mapped through entityClass when set.

      Error when item is null or undefined.

    • Delete a resource by ID.

      Parameters

      • id: ID

        Resource identifier appended to the base URL.

      Returns Promise<boolean>

      true when the request succeeds, otherwise false.

      Error when id is null or undefined.

    • Fetch one resource by ID using GET.

      Parameters

      • id: ID

        Resource identifier appended to the base URL.

      • params: Record<string, unknown> = {}

        Additional URI template or query parameters.

      Returns Promise<unknown>

      The mapped entity, raw response value, or null when empty.

      Error when id is null or undefined.

    • Fetch a collection.

      Parameters are used for URI template expansion and are also forwarded to $http as query params. Non-array responses resolve to an empty array.

      Parameters

      • params: Record<string, unknown> = {}

      Returns Promise<T[]>

    • Update a resource using PUT.

      Parameters

      • id: ID

        Resource identifier appended to the base URL.

      • item: Partial<T>

        Request body to send.

      Returns Promise<unknown>

      The updated entity, raw value, or null when the request fails.

      Error when id is null or undefined.