Do not JSON parse empty reponse
This commit is contained in:
parent
80eca30725
commit
b703ccde9b
@ -1,5 +1,9 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## v0.6.1 - _TBD, 2018_
|
||||||
|
|
||||||
|
* Fix JSON parse empty response (#407)
|
||||||
|
|
||||||
## v0.6.0 - _February 16, 2018_
|
## v0.6.0 - _February 16, 2018_
|
||||||
|
|
||||||
* Add pagination options to HttpClient methods (#393)
|
* Add pagination options to HttpClient methods (#393)
|
||||||
|
@ -172,13 +172,12 @@ export class HttpClient implements Client {
|
|||||||
body: JSON.stringify(payload),
|
body: JSON.stringify(payload),
|
||||||
headers,
|
headers,
|
||||||
});
|
});
|
||||||
const json = await response.json();
|
const text = await response.text();
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorString = `${response.status} - ${response.statusText}\n${requestType} ${url}\n${JSON.stringify(
|
const errorString = `${response.status} - ${response.statusText}\n${requestType} ${url}\n${text}`;
|
||||||
json,
|
|
||||||
)}`;
|
|
||||||
throw Error(errorString);
|
throw Error(errorString);
|
||||||
}
|
}
|
||||||
return json;
|
const result = !_.isEmpty(text) ? JSON.parse(text) : undefined;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user