Options
All
  • Public
  • Public/Protected
  • All
Menu

Class API<TGraph>

Base API class for all custom clients in this SDK. If you're building your own client, consider extending this class for consistency.

Type Parameters

Hierarchy

Index

Constructors

Properties

_cache: Storage

Resolver cache implementing Web Storage API.

_console: Consola

Shared Consola instance.

_fetch: ((input: RequestInfo, init?: RequestInit) => Promise<Response>)

Custom Fetch API implementation for making authenticated requests.

Type declaration

_path: CurieChain

Path to this resource node as base URL followed by a list of curies.

base: URL

Bookmark URL for this API. This is where the tree traversal begins. We also use this URL as a base for relative paths.

cache: Storage

Resolver cache implementing Web Storage API. Every resolved path will be stored here for future use. You can clear this cache by calling clear().

console: Consola

Consola instance. If you extend this class and add logging in your code, use this instead of native console.

storage: Storage

Credentials storage implementing Web Storage API. Access tokens and other related info will be stored here. Clearing this storage will log you out.

AuthError: typeof AuthError = AuthError
Node: typeof Node = Node
ResolutionError: typeof ResolutionError = ResolutionError
Response: typeof Response = Response
WHATWGHeaders: { prototype: Headers } = Headers

Polyfilled version of the built-in Headers class. If you need to pass an instance of Headers to .fetch(), use this class instead of the built-in one to avoid this issue.

Type declaration

  • prototype: Headers
WHATWGRequest: { prototype: Request } = Request

Polyfilled version of the built-in Request class. If you need to pass an instance of Request to .fetch(), use this class instead of the built-in one to avoid this issue.

Type declaration

WHATWGResponse: { prototype: Response; error: any; redirect: any } = Response

Polyfilled version of the built-in Response class. If you need to check the return value of .fetch(), use this class instead of the built-in one to avoid this issue.

Type declaration

  • prototype: Response
  • error:function
    • Returns Response

  • redirect:function
    • redirect(url: string, status?: number): Response
    • Parameters

      • url: string
      • Optional status: number

      Returns Response

v8n: { classConstructor: any } = ...

Type declaration

  • classConstructor: any
whatwgFetch: ((input: RequestInfo, init?: RequestInit) => Promise<Response>) = fetch

Type declaration

Methods

  • _resolve(): Promise<URL>
  • Resolves resource URL from a curie chain. The first element in the path must be a URL.

    throws

    Throws {@link APIResolutionError} when once of the resources can't be reached.

    Returns Promise<URL>

    Resolved URL.

  • delete(): Promise<Response<TGraph, undefined>>
  • Resolves the URL of this node and sends a DELETE request, removing this resource.

    Returns Promise<Response<TGraph, undefined>>

    Instance of {@link APIResponse} representing this resource.

  • follow<C>(curie: C): Node<TGraph["links"][C]>
  • Resource path builder. Calling this method instructs our SDK to find the provided curie in this resource's links and navigate to its location on request.

    Type Parameters

    • C extends string | number | symbol

    Parameters

    • curie: C

      Curie to follow.

    Returns Node<TGraph["links"][C]>

    Instance of {@link APINode} representing the resource at curie location.

  • get(): Promise<Response<TGraph, undefined>>
  • get<Q>(query: Q): Promise<Response<TGraph, Q>>
  • Resolves the URL of this node and sends a GET request using provided parameters.

    Returns Promise<Response<TGraph, undefined>>

    Instance of {@link APIResponse} representing this resource.

  • Resolves the URL of this node and sends a GET request using provided parameters.

    Type Parameters

    • Q extends Query<TGraph, Q>

    Parameters

    • query: Q

      Query parameters such as zoom, fields etc.

    Returns Promise<Response<TGraph, Q>>

    Instance of {@link APIResponse} representing this resource.

  • patch(body?: Partial<TGraph["props"]>): Promise<Response<TGraph, undefined>>
  • Resolves the URL of this node and sends a PATCH request with provided properties, updating this resource.

    Parameters

    • Optional body: Partial<TGraph["props"]>

      Partial resource object.

    Returns Promise<Response<TGraph, undefined>>

    Instance of {@link APIResponse} representing this resource.

  • post(body?: TGraph["props"]): Promise<Response<TGraph, undefined>>
  • Resolves the URL of this node and sends a POST request with provided properties, creating a resource or triggering an action.

    Parameters

    • Optional body: TGraph["props"]

      Complete resource object.

    Returns Promise<Response<TGraph, undefined>>

    Instance of {@link APIResponse} representing this resource.

  • put(body?: TGraph["props"]): Promise<Response<TGraph, undefined>>
  • Resolves the URL of this node and sends a PUT request with provided properties, replacing the existing resource.

    Parameters

    • Optional body: TGraph["props"]

      Complete resource object.

    Returns Promise<Response<TGraph, undefined>>

    Instance of {@link APIResponse} representing this resource.

Generated using TypeDoc