File tree Expand file tree Collapse file tree 3 files changed +12
-21
lines changed
packages/thirdweb/src/rpc Expand file tree Collapse file tree 3 files changed +12
-21
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " thirdweb " : patch
3+ ---
4+
5+ Simplify RPC request handling
Original file line number Diff line number Diff 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
9384type 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}
Original file line number Diff line number Diff line change @@ -144,7 +144,11 @@ export function getRpcClient(
144144
145145 // No response.
146146 if ( ! response ) {
147- inflight . reject ( new Error ( "No response" ) ) ;
147+ inflight . reject (
148+ new Error (
149+ `No response for index ${ index } - all responses: ${ stringify ( responses ) } ` ,
150+ ) ,
151+ ) ;
148152 }
149153 // Response is an error or error string.
150154 else if ( response instanceof Error ) {
You can’t perform that action at this time.
0 commit comments