diff --git a/packages/pl-api/lib/client.ts b/packages/pl-api/lib/client.ts index 456e19448..5fa25d3bf 100644 --- a/packages/pl-api/lib/client.ts +++ b/packages/pl-api/lib/client.ts @@ -248,9 +248,16 @@ class PlApiClient { close: () => void; }; - constructor(baseURL: string, accessToken?: string, { instance, fetchInstance }: { + constructor(baseURL: string, accessToken?: string, { + instance, + fetchInstance, + onInstanceFetchSuccess, + onInstanceFetchError, + }: { instance?: Instance; fetchInstance?: boolean; + onInstanceFetchSuccess?: (instance: Instance) => void; + onInstanceFetchError?: (error?: any) => void; } = {}) { this.baseURL = baseURL; this.#accessToken = accessToken; @@ -259,7 +266,7 @@ class PlApiClient { this.#setInstance(instance); } if (fetchInstance) { - this.instance.getInstance(); + this.instance.getInstance().then(onInstanceFetchSuccess).catch(onInstanceFetchError); } } diff --git a/packages/pl-api/package.json b/packages/pl-api/package.json index aa8c0c3fc..f3ba161d5 100644 --- a/packages/pl-api/package.json +++ b/packages/pl-api/package.json @@ -1,6 +1,6 @@ { "name": "pl-api", - "version": "0.1.5", + "version": "0.1.6", "type": "module", "homepage": "https://github.com/mkljczk/pl-fe/tree/fork/packages/pl-api", "repository": {