Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

fix: Always return the underlying request object #177

Merged
merged 1 commit into from
Jan 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/api/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ module.exports = send => {
}

if (typeof files === 'string' && files.startsWith('http')) {
Wreck.request('GET', files, null, (err, res) => {
return Wreck.request('GET', files, null, (err, res) => {
if (err) return cb(err)

send('add', null, opts, res, cb)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a note here that ipfsAPI().add() doesn't return the right request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

})

return
}

send('add', null, opts, files, cb)
return send('add', null, opts, files, cb)
}
}
2 changes: 1 addition & 1 deletion src/api/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const ndjson = require('ndjson')
module.exports = send => {
return {
tail (cb) {
send('log/tail', null, {}, null, false, (err, res) => {
return send('log/tail', null, {}, null, false, (err, res) => {
if (err) return cb(err)
cb(null, res.pipe(ndjson.parse()))
})
Expand Down
4 changes: 2 additions & 2 deletions src/api/pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ module.exports = send => {
opts = null
}

send('pin/add', hash, opts, null, cb)
return send('pin/add', hash, opts, null, cb)
},
remove (hash, opts, cb) {
if (typeof opts === 'function') {
cb = opts
opts = null
}

send('pin/rm', hash, opts, null, cb)
return send('pin/rm', hash, opts, null, cb)
},
list (type, cb) {
if (typeof type === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion src/request-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function requestAPI (config, path, args, qs, files, buffer, cb) {
opts.payload = stream
}

Wreck.request(opts.method, opts.uri, opts, onRes(buffer, cb))
return Wreck.request(opts.method, opts.uri, opts, onRes(buffer, cb))
}

// -- Interface
Expand Down
4 changes: 3 additions & 1 deletion test/api/log.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

describe('.log', () => {
it('.log.tail', done => {
apiClients['a'].log.tail((err, res) => {
const req = apiClients['a'].log.tail((err, res) => {
expect(err).to.not.exist

expect(req).to.exist

res.once('data', obj => {
expect(obj).to.be.an('object')
done()
Expand Down