Skip to content

Commit

Permalink
fix: api.request() was not accepting custom URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
MattCCC committed Sep 30, 2024
1 parent d3da3d0 commit 808040d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/api-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
FinalParams,
FinalResponse,
QueryParams,
RequestConfigUrlRequired,
UrlPathParams,
} from './types/api-handler';
import { createRequestHandler } from './request-handler';
Expand Down Expand Up @@ -121,7 +122,9 @@ function createApiFetcher<
> = {},
): Promise<FetchResponse<FinalResponse<ResponseData, DefaultResponse>>> {
// Use global per-endpoint settings
const endpointConfig = endpoints[endpointName as string];
const endpointConfig =
endpoints[endpointName] ||
({ url: endpointName as string } as RequestConfigUrlRequired);

const responseData = await requestHandler.request<
FinalResponse<ResponseData, DefaultResponse>,
Expand Down
4 changes: 3 additions & 1 deletion src/types/api-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ type DefaultEndpoints<EndpointsSettings> = {
[K in keyof EndpointsSettings]: EndpointDefaults;
};

type RequestConfigUrlRequired = Omit<RequestConfig, 'url'> & { url: string };
export type RequestConfigUrlRequired = Omit<RequestConfig, 'url'> & {
url: string;
};

/**
* Configuration for API endpoints, where each key is an endpoint name or string, and the value is the request configuration.
Expand Down

0 comments on commit 808040d

Please sign in to comment.