Skip to content

Commit 16501dd

Browse files
fix: tsRestFetchApi content type parsing (#338)
* fix client logic * changeset * linting
1 parent d122bb7 commit 16501dd

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

.changeset/four-days-wonder.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ts-rest/core': minor
3+
---
4+
5+
tsRestFetchApi should be more flexible when determining application/json content type header

libs/ts-rest/core/src/lib/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const tsRestFetchApi: ApiFetcher = async ({
9191
});
9292
const contentType = result.headers.get('content-type');
9393

94-
if (contentType?.includes('application/json')) {
94+
if (contentType?.includes("application/") && contentType?.includes('json')) {
9595
return {
9696
status: result.status,
9797
body: await result.json(),

0 commit comments

Comments
 (0)