fix: handle non-json api error responses
This commit is contained in:
+5
-5
@@ -19,12 +19,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var payload = null;
|
var payload = null;
|
||||||
var text = '';
|
var text = await response.text();
|
||||||
|
|
||||||
try {
|
if (text) {
|
||||||
payload = await response.json();
|
try {
|
||||||
} catch (_error) {
|
payload = JSON.parse(text);
|
||||||
text = await response.text();
|
} catch (_error) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
Reference in New Issue
Block a user