Interface HttpApi

This API provides functionality for making REST requests.

Accessed from the window at window.sas.vi.http

window.sas.vi.http.get("example_url", {...})
interface HttpApi {
    delete(url: string, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "text";
    }): Promise<HttpResponse<string>>;
    delete<R>(url: string, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "json";
    }): Promise<HttpResponse<R>>;
    delete(url: string, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "blob";
    }): Promise<HttpResponse<Blob>>;
    get(url: string, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "text";
    }): Promise<HttpResponse<string>>;
    get<R>(url: string, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "json";
    }): Promise<HttpResponse<R>>;
    get(url: string, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "blob";
    }): Promise<HttpResponse<Blob>>;
    head(url: string, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
    }): Promise<HttpResponse<null>>;
    options(url: string, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "text";
    }): Promise<HttpResponse<string>>;
    options<R>(url: string, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "json";
    }): Promise<HttpResponse<R>>;
    options(url: string, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "blob";
    }): Promise<HttpResponse<Blob>>;
    patch(url: string, body: any, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "text";
    }): Promise<HttpResponse<string>>;
    patch<R>(url: string, body: any, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "json";
    }): Promise<HttpResponse<R>>;
    patch(url: string, body: any, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "blob";
    }): Promise<HttpResponse<Blob>>;
    post(url: string, body: any, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "text";
    }): Promise<HttpResponse<string>>;
    post<R>(url: string, body: any, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "json";
    }): Promise<HttpResponse<R>>;
    post(url: string, body: any, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "blob";
    }): Promise<HttpResponse<Blob>>;
    put(url: string, body: any, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "text";
    }): Promise<HttpResponse<string>>;
    put<R>(url: string, body: any, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "json";
    }): Promise<HttpResponse<R>>;
    put(url: string, body: any, options?: {
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "blob";
    }): Promise<HttpResponse<Blob>>;
    request(method: string, url: string, options?: {
        body?: any;
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "text";
    }): Promise<HttpResponse<string>>;
    request<R>(method: string, url: string, options?: {
        body?: any;
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "json";
    }): Promise<HttpResponse<R>>;
    request(method: string, url: string, options?: {
        body?: any;
        headers?: Record<string, string | string[]>;
        params?: Record<string, string | string[]>;
        responseType: "blob";
    }): Promise<HttpResponse<Blob>>;
}

Methods

  • Parameters

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "text";
      }

      {HttpApi~StringRequestOptions} HTTP options.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "text"

    Returns Promise<HttpResponse<string>>

    A Promise of the HttpResponse for the request. The response body is a string.

    Constructs a DELETE request that interprets the body as a text stream and returns the full HttpResponse.

  • Type Parameters

    • R

    Parameters

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "json";
      }

      {HttpApi~JsonRequestOptions} HTTP options.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "json"

    Returns Promise<HttpResponse<R>>

    A Promise of the HttpResponse for the request. The response body is an object of type R.

    Constructs a DELETE request that interprets the body as a JSON object and returns the full HttpResponse.

  • Parameters

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "blob";
      }

      {HttpApi~BlobRequestOptions} HTTP options.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "blob"

    Returns Promise<HttpResponse<Blob>>

    A Promise of the HttpResponse for the request. The response body is a Blob.

    Constructs a DELETE request that interprets the body as a Blob and returns the full HttpResponse.

  • Parameters

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "text";
      }

      {HttpApi~StringRequestOptions} HTTP options to send with the request.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "text"

    Returns Promise<HttpResponse<string>>

    A Promise of the HttpResponse for the request. The response body is a string.

    Constructs a GET request that interprets the body as a text stream and returns the full HttpResponse.

  • Type Parameters

    • R

    Parameters

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "json";
      }

      {HttpApi~JsonRequestOptions} HTTP options to send with the request.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "json"

    Returns Promise<HttpResponse<R>>

    A Promise of the HttpResponse for the request. The response body is an object of type R.

    Constructs a GET request that interprets the body as a JSON object and returns the full HttpResponse.

  • Parameters

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "blob";
      }

      {HttpApi~BlobRequestOptions} HTTP options to send with the request.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "blob"

    Returns Promise<HttpResponse<Blob>>

    A Promise of the HttpResponse for the request. The response body is a Blob.

    Constructs a GET request that interprets the body as a Blob and returns the full HttpResponse.

  • Parameters

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
      }

      {HttpApi~HeadOptions} HTTP options to send with the request.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>

    Returns Promise<HttpResponse<null>>

    A Promise of the HttpResponse for the request with the response body of null.

    Constructs a HEAD request that returns a null body and the full HttpResponse.

  • Parameters

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "text";
      }

      {HttpApi~StringRequestOptions} HTTP options.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "text"

    Returns Promise<HttpResponse<string>>

    A Promise of the HttpResponse for the request. The response body is a string.

    Constructs an OPTIONS request that interprets the body as a text stream and returns the full HttpResponse.

  • Type Parameters

    • R

    Parameters

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "json";
      }

      {HttpApi~JsonRequestOptions} HTTP options.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "json"

    Returns Promise<HttpResponse<R>>

    A Promise of the HttpResponse for the request. The response body is an object of type R.

    Constructs an OPTIONS request that interprets the body as a JSON object and returns the full HttpResponse.

  • Parameters

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "blob";
      }

      {HttpApi~BlobRequestOptions} HTTP options.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "blob"

    Returns Promise<HttpResponse<Blob>>

    A Promise of the HttpResponse for the request. The response body is a Blob.

    Constructs an OPTIONS request that interprets the body as a Blob and returns the full HttpResponse.

  • Parameters

    • url: string

      {string} Endpoint URL.

    • body: any

      {(any|null)} Content to replace with current content.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "text";
      }

      {HttpApi~StringRequestOptions} HTTP options.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "text"

    Returns Promise<HttpResponse<string>>

    A Promise of the HttpResponse for the request. The response body is a string.

    Constructs a PATCH request that interprets the body as a text stream and returns the full HttpResponse.

  • Type Parameters

    • R

    Parameters

    • url: string

      {string} Endpoint URL.

    • body: any

      {(any|null)} Content to replace with current content.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "json";
      }

      {HttpApi~JsonRequestOptions} HTTP options.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "json"

    Returns Promise<HttpResponse<R>>

    A Promise of the HttpResponse for the request. The response body is an object of type R.

    Constructs a PATCH request that interprets the body as a JSON object and returns the full HttpResponse.

  • Parameters

    • url: string

      {string} Endpoint URL.

    • body: any

      {(any|null)} Content to replace with current content.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "blob";
      }

      {HttpApi~BlobRequestOptions} HTTP options.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "blob"

    Returns Promise<HttpResponse<Blob>>

    A Promise of the HttpResponse for the request. The response body is a Blob.

    Constructs a PATCH request that interprets the body as a Blob and returns the full HttpResponse.

  • Parameters

    • url: string

      {string} Endpoint URL.

    • body: any

      {(any|null)} Content to replace with current content.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "text";
      }

      {HttpApi~StringRequestOptions} HTTP options

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "text"

    Returns Promise<HttpResponse<string>>

    A Promise of the HttpResponse for the request. The response body is a string.

    Constructs a POST request that interprets the body as a text stream and returns the full HttpResponse.

  • Type Parameters

    • R

    Parameters

    • url: string

      {string} Endpoint URL.

    • body: any

      {(any|null)} Content to replace with current content.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "json";
      }

      {HttpApi~JsonRequestOptions} HTTP options

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "json"

    Returns Promise<HttpResponse<R>>

    A Promise of the HttpResponse for the request. The response body is an object of type R.

    Constructs a POST request that interprets the body as a JSON object and returns the full HttpResponse.

  • Parameters

    • url: string

      {string} Endpoint URL.

    • body: any

      {(any|null)} Content to replace with current content.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "blob";
      }

      {HttpApi~BlobRequestOptions} HTTP options

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "blob"

    Returns Promise<HttpResponse<Blob>>

    A Promise of the HttpResponse for the request. The response body is a Blob.

    Constructs a POST request that interprets the body as a Blob and returns the full HttpResponse.

  • Parameters

    • url: string

      {string} Endpoint URL.

    • body: any

      {(any|null)} Content to replace with current content.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "text";
      }

      {HttpApi~StringRequestOptions} HTTP options.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "text"

    Returns Promise<HttpResponse<string>>

    A Promise of the HttpResponse for the request. The response body is a string.

    Constructs a PUT request that interprets the body as a text stream and returns the full HttpResponse.

  • Type Parameters

    • R

    Parameters

    • url: string

      {string} Endpoint URL.

    • body: any

      {(any|null)} Content to replace with current content.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "json";
      }

      {HttpApi~JsonRequestOptions} HTTP options.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "json"

    Returns Promise<HttpResponse<R>>

    A Promise of the HttpResponse for the request. The response body is an object of type R.

    Constructs a PUT request that interprets the body as a JSON object and returns the full HttpResponse.

  • Parameters

    • url: string

      {string} Endpoint URL.

    • body: any

      {(any|null)} Content to replace with current content.

    • Optionaloptions: {
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "blob";
      }

      {HttpApi~BlobRequestOptions} HTTP options.

      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "blob"

    Returns Promise<HttpResponse<Blob>>

    A Promise of the HttpResponse for the request. The response body is a Blob.

    Constructs a PUT request that interprets the body as a Blob and returns the full HttpResponse.

  • Parameters

    • method: string

      {string}

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          body?: any;
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "text";
      }

      {HttpApi~StringGenericRequestOptions} HTTP options.

      • Optionalbody?: any
      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "text"

    Returns Promise<HttpResponse<string>>

    A Promise of the HttpResponse for the request. The response body is a string.

    Constructs a request that interprets the body as a text stream and returns the full HttpResponse.

  • Type Parameters

    • R

    Parameters

    • method: string

      {string}

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          body?: any;
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "json";
      }

      {HttpApi~JsonGenericRequestOptions} HTTP options.

      • Optionalbody?: any
      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "json"

    Returns Promise<HttpResponse<R>>

    A Promise of the HttpResponse for the request. The response body is an object of type R.

    Constructs a request that interprets the body as a JSON object and returns the full HttpResponse.

  • Parameters

    • method: string

      {string}

    • url: string

      {string} Endpoint URL.

    • Optionaloptions: {
          body?: any;
          headers?: Record<string, string | string[]>;
          params?: Record<string, string | string[]>;
          responseType: "blob";
      }

      {HttpApi~BlobGenericRequestOptions} HTTP options.

      • Optionalbody?: any
      • Optionalheaders?: Record<string, string | string[]>
      • Optionalparams?: Record<string, string | string[]>
      • responseType: "blob"

    Returns Promise<HttpResponse<Blob>>

    A Promise of the HttpResponse for the request. The response body is a Blob.

    Constructs a request that interprets the body as a Blob and returns the full HttpResponse.