Skip to content
This repository was archived by the owner on Jul 4, 2024. It is now read-only.

Commit 7c4fae5

Browse files
committed
fix: sometime we get a json header but not a valid json in the body
1 parent 3e63568 commit 7c4fae5

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

mod.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,11 @@ axiod.request = <T = any>({
227227
// Data
228228
let _data: any = null;
229229

230-
// Check content type and then do the needed transformations
231-
const contentType = x.headers.get("content-type") || "";
232-
if (contentType.toLowerCase().indexOf("json") === -1) {
233-
// Try to convert to json
234-
try {
235-
_data = await x.clone().json();
236-
} catch (ex) {
237-
_data = await x.clone().text();
238-
}
239-
} else {
230+
// Try to convert to json
231+
try {
240232
_data = await x.clone().json();
233+
} catch (ex) {
234+
_data = await x.clone().text();
241235
}
242236

243237
// transformResponse

0 commit comments

Comments
 (0)