Skip to content

Commit 36dc993

Browse files
authored
fix: Reject with json if request fails with json (#984)
* fix: Reject with json if request fails with json * handle not json case * refactor * Update package.json
1 parent f976ab7 commit 36dc993

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@snapshot-labs/snapshot.js",
3-
"version": "0.11.14",
3+
"version": "0.11.15",
44
"repository": "snapshot-labs/snapshot.js",
55
"license": "MIT",
66
"main": "dist/snapshot.cjs.js",

src/sign/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ export default class Client {
107107
fetch(address, init)
108108
.then((res) => {
109109
if (res.ok) return resolve(res.json());
110+
if (res.headers.get('content-type')?.includes('application/json'))
111+
return res.json().then(reject).catch(reject);
110112
throw res;
111113
})
112-
.catch((e) => reject(e));
114+
.catch(reject);
113115
});
114116
}
115117

0 commit comments

Comments
 (0)