diff --git a/lib/http/client.js b/lib/http/client.js index b9e1ac2a..73896cf9 100644 --- a/lib/http/client.js +++ b/lib/http/client.js @@ -225,9 +225,6 @@ HTTPClient.prototype._request = async function _request(method, endpoint, json) if (res.statusCode === 401) throw new Error('Unauthorized (bad API key).'); - if (res.statusCode !== 200) - throw new Error(`Status code: ${res.statusCode}.`); - if (res.type !== 'json') throw new Error('Bad response (wrong content-type).'); @@ -242,6 +239,9 @@ HTTPClient.prototype._request = async function _request(method, endpoint, json) if (res.body.error) throw new Error(res.body.error.message); + if (res.statusCode !== 200) + throw new Error(`Status code: ${res.statusCode}.`); + return res.body; };