@inweb/client
    Preparing search index...

    Interface IHttpClient

    Defines the HTTP client used to send requests to the REST API server.

    interface IHttpClient {
        headers: HeadersInit;
        serverUrl: string;
        signInUserId: string;
        signInUserIsAdmin: boolean;
        delete(relativePath: string, init?: RequestInit): Promise<Response>;
        downloadFile(
            relativePath: string,
            onProgress?: (progress: number, chunk: Uint8Array) => void,
            init?: RequestInit,
        ): Promise<Response>;
        downloadFileRange(
            relativePath: string,
            reserved: string | number,
            ranges: { begin: number; end: number; requestId: number }[],
            onProgress?: (
                progress: number,
                chunk: Uint8Array,
                requestId: number,
            ) => void,
            init?: RequestInit,
        ): Promise<Response>;
        get(relativePath: string, init?: RequestInit): Promise<Response>;
        post(
            relativePath: string,
            body?: object | BodyInit,
            init?: RequestInit,
        ): Promise<Response>;
        put(
            relativePath: string,
            body?: object | BodyInit,
            init?: RequestInit,
        ): Promise<Response>;
        uploadFile(
            relativePath: string,
            file: File,
            onProgress?: (progress: number) => void,
            init?: RequestInit,
        ): Promise<XMLHttpRequest>;
    }
    Index

    Properties

    headers: HeadersInit

    Default HTTP headers for all requests. You can add specific headers at any time.

    The following headers are added automatically:

    • Authorization- Added after user log in.
    • Content-Type - Added before sending POST and PUT request according the request body.
    serverUrl: string

    REST API server URL.

    signInUserId: string

    Current logged in user ID.

    signInUserIsAdmin: boolean

    True if the current logged in user is and administrator.

    Methods

    • Sends the DELETE request to the specified endpoint.

      Parameters

      • relativePath: string

        Endpoint relative path.

      • Optionalinit: RequestInit

        A set of options that can be used to configure a fetch request. See RequestInit for more details.

      Returns Promise<Response>

    • Downloads the specified file from the server.

      Parameters

      • relativePath: string

        Download endpoint relative path.

      • OptionalonProgress: (progress: number, chunk: Uint8Array) => void

        Download progress callback.

      • Optionalinit: RequestInit

        A set of options that can be used to configure a fetch request. See RequestInit for more details.

      Returns Promise<Response>

    • Downloads a part of file from the server.

      Parameters

      • relativePath: string

        Download endpoint relative path.

      • reserved: string | number

        Reserved, do not use.

      • ranges: { begin: number; end: number; requestId: number }[]

        A ranges of resource file contents to download. See HTTP range requests for more details.

      • OptionalonProgress: (progress: number, chunk: Uint8Array, requestId: number) => void

        Download progress callback.

      • Optionalinit: RequestInit

        A set of options that can be used to configure a fetch request. See RequestInit for more details.

      Returns Promise<Response>

    • Sends the GET request to the specified endpoint.

      Parameters

      • relativePath: string

        Endpoint relative path.

      • Optionalinit: RequestInit

        A set of options that can be used to configure a fetch request. See RequestInit for more details.

      Returns Promise<Response>

    post

    • post(
          relativePath: string,
          body?: object | BodyInit,
          init?: RequestInit,
      ): Promise<Response>

      Sends the POST request to the specified endpoint.

      Parameters

      • relativePath: string

        Endpoint relative path.

      • Optionalbody: object | BodyInit

        Request body. Can be FormData, ArrayBuffer, Blob, JSON object or plain text.

      • Optionalinit: RequestInit

        A set of options that can be used to configure a fetch request. See RequestInit for more details.

      Returns Promise<Response>

    • Sends the PUT request to the specified endpoint.

      Parameters

      • relativePath: string

        Endpoint relative path.

      • Optionalbody: object | BodyInit

        Request body. Can be FormData, ArrayBuffer, Blob, JSON object or plain text.

      • Optionalinit: RequestInit

        A set of options that can be used to configure a fetch request. See RequestInit for more details.

      Returns Promise<Response>

    • Upload a file to the server.

      Parameters

      • relativePath: string

        Upload endpoint relative path.

      • file: File

        Web API File object are generally retrieved from a FileList object returned as a result of a user selecting files using the HTML <input> element.

      • OptionalonProgress: (progress: number) => void

        Upload progress callback.

      • Optionalinit: RequestInit

        A set of options that can be used to configure a fetch request. See RequestInit for more details.

      Returns Promise<XMLHttpRequest>