Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit eab227d

Browse files
BigOsvaapsoedirgo
andauthored
fix: Fetch method can't handle error response that is not a valid JSON (#242)
* fix: Fetch method can't handle error response that is not a valid JSON * fix: can't reuse response object Co-authored-by: Bobbie Soedirgo <[email protected]>
1 parent ff790ca commit eab227d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/lib/types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,15 @@ export abstract class PostgrestBuilder<T> implements PromiseLike<PostgrestRespon
124124
count = parseInt(contentRange[1])
125125
}
126126
} else {
127-
error = await res.json()
127+
const body = await res.text()
128+
129+
try {
130+
error = JSON.parse(body)
131+
} catch {
132+
error = {
133+
message: body
134+
}
135+
}
128136

129137
if (error && this.shouldThrowOnError) {
130138
throw error

0 commit comments

Comments
 (0)