From 808040d3d7affaa5d19c45db1492cc6a1b8bbe9e Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 30 Sep 2024 23:24:19 +0200 Subject: [PATCH] fix: api.request() was not accepting custom URLs --- src/api-handler.ts | 5 ++++- src/types/api-handler.ts | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/api-handler.ts b/src/api-handler.ts index a0d20dd..15f6374 100644 --- a/src/api-handler.ts +++ b/src/api-handler.ts @@ -13,6 +13,7 @@ import type { FinalParams, FinalResponse, QueryParams, + RequestConfigUrlRequired, UrlPathParams, } from './types/api-handler'; import { createRequestHandler } from './request-handler'; @@ -121,7 +122,9 @@ function createApiFetcher< > = {}, ): Promise>> { // 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, diff --git a/src/types/api-handler.ts b/src/types/api-handler.ts index 2c1f59a..d786b6f 100644 --- a/src/types/api-handler.ts +++ b/src/types/api-handler.ts @@ -149,7 +149,9 @@ type DefaultEndpoints = { [K in keyof EndpointsSettings]: EndpointDefaults; }; -type RequestConfigUrlRequired = Omit & { url: string }; +export type RequestConfigUrlRequired = Omit & { + url: string; +}; /** * Configuration for API endpoints, where each key is an endpoint name or string, and the value is the request configuration.