1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2024-11-22 01:36:56 +01:00

Revert "Fix Issue 50: connection.js remove onlyJsonResponse"

This reverts commit 3c9ff5c384.
This commit is contained in:
michielmulders 2017-08-15 21:18:20 +02:00 committed by Tim Daubenschütz
parent 5ec5df7e1d
commit a5509a0171
2 changed files with 7 additions and 4 deletions

View File

@ -89,8 +89,9 @@ export default class Connection {
* @public
* @param publicKey
* @param spent
* @param onlyJsonResponse
*/
listOutputs(publicKey, spent) {
listOutputs(publicKey, spent, onlyJsonResponse = true) {
const query = {
public_key: publicKey
}
@ -101,7 +102,7 @@ export default class Connection {
}
return this._req(this.getApiUrls('outputs'), {
query
})
}, onlyJsonResponse)
}
/**
@ -158,6 +159,7 @@ export default class Connection {
/**
* @public
*
* @param transaction
*/
postTransaction(transaction) {
@ -170,6 +172,7 @@ export default class Connection {
/**
* @public
*
* @param search
*/
searchAssets(search) {

View File

@ -12,7 +12,7 @@ const DEFAULT_REQUEST_CONFIG = {
* Small wrapper around js-utility-belt's request that provides url resolving,
* default settings, and response handling.
*/
export default function request(url, config = {}) {
export default function request(url, config = {}, onlyJsonResponse = true) {
// Load default fetch configuration and remove any falsy query parameters
const requestConfig = Object.assign({}, DEFAULT_REQUEST_CONFIG, config, {
query: config.query && sanitize(config.query)
@ -30,7 +30,7 @@ export default function request(url, config = {}) {
}
return baseRequest(apiUrl, requestConfig)
.then(res => (res.json()))
.then(res => (onlyJsonResponse ? res.json() : { json: res.json(), url: res.url }))
.catch(err => {
console.error(err)
throw err