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