Skip to content

Commit

Permalink
Fixed a bug encountered when using nonResourcesUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
kahirokunn committed May 9, 2024
1 parent 96a7f16 commit 617edc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/kubekit-client/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 6 additions & 2 deletions packages/kubekit-client/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export async function apiClient<Response>(
...removeNullableProperties(extraOptions),
};

let { path, method, params, body, contentType } = { ...arguments_ };
let { path, method, params = {}, body, contentType } = { ...arguments_ };

let httpsOptions: https.RequestOptions = {
path,
Expand Down Expand Up @@ -319,9 +319,13 @@ export async function apiClient<Response>(
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);
Expand Down

0 comments on commit 617edc3

Please sign in to comment.