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

fix: handle missing daemon errors #445

Merged
merged 1 commit into from
Nov 24, 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
4 changes: 2 additions & 2 deletions examples/files-api/files-api.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'

var ipfs = require('../src')('localhost', 5001)
var ipfs = require('../../src')('localhost', 5001)

ipfs.files.ls('/folder1', function (err, res) {
if (err) {
return console.log(err)
return console.log('got an error', err)
}
if (res.readable) {
res.pipe(process.stdout)
Expand Down
4 changes: 4 additions & 0 deletions src/request-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ function requestAPI (config, options, callback) {
headers: headers
}, onRes(options.buffer, callback))

req.on('error', (err) => {
callback(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

you should use to avoid having double callback calls

const once = require('once')
callback = once(callback)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is already done, see above :)

Copy link
Contributor

Choose a reason for hiding this comment

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

:)

})

if (options.files) {
stream.pipe(req)
} else {
Expand Down