diff --git a/package.json b/package.json index 159bbd2..501265a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uschuster/webapp-scaffold", - "version": "0.3.4", + "version": "0.3.5", "description": "Shared build scripts + Vite config factories for webapp-template-derived projects.", "type": "module", "bin": { diff --git a/src/core-fetch.ts b/src/core-fetch.ts index a165531..f7c9da8 100644 --- a/src/core-fetch.ts +++ b/src/core-fetch.ts @@ -191,12 +191,18 @@ function safeJson(text: string): unknown | null { * JSON (may be null when the body isn't parseable). */ async function readBody(r: Response): Promise<[string, unknown | null]> { + // Some mocks expose .json() but not .clone() (e.g. vitest object mocks). + // Try .json() directly; if it throws, fall back to .text(). try { - const j = await r.clone().json(); + const j = await r.json(); return [JSON.stringify(j), j]; } catch { - const text = await r.text().catch(() => ''); - return [text, safeJson(text)]; + try { + const text = await r.text(); + return [text, safeJson(text)]; + } catch { + return ['', null]; + } } }