Bug 40173: Return the response early if the caller needs it
We returned the response too late: if something was wrong we processed
the response already and thrown an error.
This may introduce side-effects but it feels like a correct change.
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 14635a2db4)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
fc419ce2ef
commit
0df46127d7
|
|
@ -68,6 +68,11 @@ class HttpClient {
|
|||
const is_json = response.headers
|
||||
.get("content-type")
|
||||
?.includes("application/json");
|
||||
|
||||
if (return_response || !is_json) {
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
return response.text().then(text => {
|
||||
let message;
|
||||
|
|
@ -83,9 +88,6 @@ class HttpClient {
|
|||
throw new Error(message);
|
||||
});
|
||||
}
|
||||
if (return_response || !is_json) {
|
||||
return response;
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(result => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue