Lines 38-47
class HttpClient {
Link Here
|
38 |
headers: { ...this._headers, ...headers }, |
38 |
headers: { ...this._headers, ...headers }, |
39 |
}) |
39 |
}) |
40 |
.then(response => { |
40 |
.then(response => { |
|
|
41 |
const is_json = response.headers.get("content-type")?.includes("application/json"); |
41 |
if (!response.ok) { |
42 |
if (!response.ok) { |
42 |
return response.text().then(text => { |
43 |
return response.text().then(text => { |
43 |
let message; |
44 |
let message; |
44 |
if (text) { |
45 |
if (text && is_json) { |
45 |
let json = JSON.parse(text); |
46 |
let json = JSON.parse(text); |
46 |
message = |
47 |
message = |
47 |
json.error || |
48 |
json.error || |
Lines 53-59
class HttpClient {
Link Here
|
53 |
throw new Error(message); |
54 |
throw new Error(message); |
54 |
}); |
55 |
}); |
55 |
} |
56 |
} |
56 |
return return_response ? response : response.json(); |
57 |
if ( return_response || !is_json ) { |
|
|
58 |
return response; |
59 |
} |
60 |
return response.json(); |
57 |
}) |
61 |
}) |
58 |
.then(result => { |
62 |
.then(result => { |
59 |
res = result; |
63 |
res = result; |
60 |
- |
|
|