Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 653 Bytes

File metadata and controls

33 lines (27 loc) · 653 Bytes

Custom fetch and HttpClient Injection

Custom fetch

const sdk = new LilySdk({
  baseUrl: 'https://api.lily.io',
  apiKey: 'lk_live_xxx',
  fetch: customFetchImplementation,
});

Custom HttpClient

import type { HttpClient } from 'lily-sdk/http';

class MyCustomClient implements HttpClient {
  async request<TResponse, TRequest>(
    req: HttpRequest<TRequest>,
  ): Promise<HttpResponse<TResponse>> {
    return { status: 200, headers: new Headers(), data: {} as TResponse };
  }
}

const sdk = new LilySdk(
  {
    baseUrl: 'https://api.lily.io',
    apiKey: 'lk_live_xxx',
  },
  new MyCustomClient(),
);