diff --git a/packages/clerk-js/src/core/resources/Base.ts b/packages/clerk-js/src/core/resources/Base.ts index d8d297cd4ed..0af7b04e9c7 100644 --- a/packages/clerk-js/src/core/resources/Base.ts +++ b/packages/clerk-js/src/core/resources/Base.ts @@ -35,8 +35,7 @@ export abstract class BaseResource { | ClerkResourceJSON[] | DeletedObjectJSON | DeletedObjectJSON[] - | ClerkPaginatedResponse - | null, + | ClerkPaginatedResponse, >(requestInit: FapiRequestInit, opts: BaseFetchOptions = {}): Promise> { if (!BaseResource.fapiClient) { clerkMissingFapiClientInResources(); @@ -105,7 +104,7 @@ export abstract class BaseResource { protected abstract fromJSON(data: ClerkResourceJSON | null): this; - protected async _baseGet(opts: BaseFetchOptions = {}): Promise { + protected async _baseGet(opts: BaseFetchOptions = {}): Promise { const json = await BaseResource._fetch( { method: 'GET', @@ -115,10 +114,10 @@ export abstract class BaseResource { opts, ); - return this.fromJSON((json?.response || json) as J); + return this.fromJSON(json?.response || json); } - protected async _baseMutate({ + protected async _baseMutate({ action, body, method = 'POST', @@ -129,14 +128,14 @@ export abstract class BaseResource { path: path || this.path(action), body, }); - return this.fromJSON((json?.response || json) as J); + return this.fromJSON(json?.response || json); } - protected async _basePost(params: BaseMutateParams = {}): Promise { + protected async _basePost(params: BaseMutateParams = {}): Promise { return this._baseMutate({ ...params, method: 'POST' }); } - protected async _basePut(params: BaseMutateParams = {}): Promise { + protected async _basePut(params: BaseMutateParams = {}): Promise { return this._baseMutate({ ...params, method: 'PUT' }); } @@ -144,7 +143,7 @@ export abstract class BaseResource { return this._baseMutate({ ...params, method: 'PATCH' }); } - protected async _baseDelete(params: BaseMutateParams = {}): Promise { + protected async _baseDelete(params: BaseMutateParams = {}): Promise { await this._baseMutate({ ...params, method: 'DELETE' }); }