mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2025-02-14 21:10:32 +01:00
Issue 31: make baseRequest throw payload messages not simply res
This commit is contained in:
parent
e34917ea2b
commit
9914192cf7
@ -74,7 +74,10 @@ export default function baseRequest(url, { jsonBody, query, urlTemplateSpec, ...
|
|||||||
// If status is not a 2xx (based on Response.ok), assume it's an error
|
// If status is not a 2xx (based on Response.ok), assume it's an error
|
||||||
// See https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch/fetch
|
// See https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch/fetch
|
||||||
if (!(res && res.ok)) {
|
if (!(res && res.ok)) {
|
||||||
throw res
|
return res.json().then(json => {
|
||||||
|
const error = new Error(json.message || res.statusText)
|
||||||
|
return Promise.reject(Object.assign(error, { res }))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user