1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2024-12-29 08:07:51 +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
parent e99b4b9874
commit fee4530d5c
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