Skip to content

Commit ec8190c

Browse files
committed
prevent body parsing before apiError
1 parent 1ad1721 commit ec8190c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/cloud/lib/hooks/useCloudApi.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,14 @@ export function useCloudApi() {
216216
}
217217
},
218218
onError: async (err: any) => {
219-
const error = Object.assign({}, err) as any
220-
if (
221-
error.response != null &&
222-
typeof error.response.text === 'function'
223-
) {
219+
if (err.response != null && typeof err.response.text === 'function') {
220+
const response = Object.assign({}, err.response)
224221
try {
225-
const description = (await error.response.text())
222+
const description = (await response.text())
226223
.split('\n')[0]
227224
.split(': ')
228225
if (
229-
error.response.status === 403 &&
226+
response.status === 403 &&
230227
description.some((desc: any) =>
231228
(desc || '').includes(
232229
`Your space exceeds the free tier's capacity`

0 commit comments

Comments
 (0)