Skip to content

Commit 48b3055

Browse files
[thirdweb] Simplify RPC request handling
1 parent 1825ac8 commit 48b3055

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

.changeset/orange-icons-hide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Simplify RPC request handling

packages/thirdweb/src/rpc/fetch-rpc.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,7 @@ export async function fetchRpc(
7878
);
7979
}
8080

81-
if (response.headers.get("Content-Type")?.startsWith("application/json")) {
82-
return await response.json();
83-
}
84-
const text = await response.text();
85-
try {
86-
return JSON.parse(text);
87-
} catch (err) {
88-
console.error("Error parsing response", err, text);
89-
throw err;
90-
}
81+
return await response.json();
9182
}
9283

9384
type FetchSingleRpcOptions = {
@@ -121,14 +112,5 @@ export async function fetchSingleRpc(
121112
`RPC request failed with status ${response.status} - ${response.statusText}: ${error || "unknown error"}`,
122113
);
123114
}
124-
if (response.headers.get("Content-Type")?.startsWith("application/json")) {
125-
return await response.json();
126-
}
127-
const text = await response.text();
128-
try {
129-
return JSON.parse(text);
130-
} catch (err) {
131-
console.error("Error parsing response", err, text);
132-
throw err;
133-
}
115+
return await response.json();
134116
}

0 commit comments

Comments
 (0)