Skip to content

Commit 0a3e62f

Browse files
committed
fix(http): Only parse response as JSON of 4xx errors
1 parent f1da62a commit 0a3e62f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

js/cloudopt-core.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,9 @@ cloudopt.http = (function (cloudopt) {
12431243
const _result = await $.ajax(this.option);
12441244
resolve(_result)
12451245
} catch (error) {
1246-
const _response = (error && (typeof error.responseText === 'string')) ? JSON.parse(error.responseText) : {}
1246+
var _response = {};
1247+
if (error && error.status && error.status >= 400 && error.status < 500 && (typeof error.responseText === 'string'))
1248+
_response = JSON.parse(error.responseText)
12471249
if (isResolveErr) this.handleHttpErrorStatus(_response);
12481250
reject(_response)
12491251
cloudopt.logger.debug(error.responseText)

0 commit comments

Comments
 (0)