From 617edc3985578f4bf549d2ea73ccd787449c9d5b Mon Sep 17 00:00:00 2001 From: kahirokunn Date: Thu, 9 May 2024 16:26:33 +0900 Subject: [PATCH] Fixed a bug encountered when using nonResourcesUrl --- packages/kubekit-client/package.json | 2 +- packages/kubekit-client/src/client/index.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/kubekit-client/package.json b/packages/kubekit-client/package.json index 721a4efd..99083a88 100644 --- a/packages/kubekit-client/package.json +++ b/packages/kubekit-client/package.json @@ -1,6 +1,6 @@ { "name": "@kubekit/client", - "version": "0.0.21", + "version": "0.0.23", "main": "lib/index.js", "types": "lib/index.d.ts", "author": "kahirokunn", diff --git a/packages/kubekit-client/src/client/index.ts b/packages/kubekit-client/src/client/index.ts index bc1c9d7e..1b990378 100644 --- a/packages/kubekit-client/src/client/index.ts +++ b/packages/kubekit-client/src/client/index.ts @@ -173,7 +173,7 @@ export async function apiClient( ...removeNullableProperties(extraOptions), }; - let { path, method, params, body, contentType } = { ...arguments_ }; + let { path, method, params = {}, body, contentType } = { ...arguments_ }; let httpsOptions: https.RequestOptions = { path, @@ -319,9 +319,13 @@ export async function apiClient( return (await response.json()) as Response; } - // helpful message for debugging const text = await response.text(); + if (isSuccess) { + // TODO: This is to bypass a type error, but it should be properly addressed. + return text as Response; + } if (response.status === 404 && text.includes('404 page not found')) { + // helpful message for debugging console.info(`Did you forget to install your Custom Resources Definitions? path: ${httpsOptions.path}`); } throw new Error(text);