Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit 710d0a2

Browse files
Allow to access server-side text response
1 parent d1d0b3a commit 710d0a2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ program
5050
directory,
5151
...command,
5252
})
53-
json = await res.json()
53+
const text = await res.text()
54+
try {
55+
json = JSON.parse(text)
56+
} catch (error) {
57+
throw new Error(`${res.status}: Failed to parse response body as JSON:\n\n${text}`)
58+
}
5459

5560
if (json.error) {
5661
throw new UploadError(json.error.message)

0 commit comments

Comments
 (0)