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

Implement dag.get #549

Closed
wants to merge 1 commit into from
Closed
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
35 changes: 34 additions & 1 deletion src/api/dag.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,40 @@ module.exports = (send) => {
}
}),
get: promisify((cid, path, options, callback) => {
// TODO
if (typeof path === 'function') {
callback = path
path = undefined
}

if (typeof options === 'function') {
callback = options
options = {}
}

options = options || {}

if (typeof cid === 'string') {
const split = cid.split('/')
cid = split[0]
split.shift()

if (split.length > 0) {
path = split.join('/')
} else {
path = '/'
}
}

send({
path: 'dag/get',
args: cid + path,
qs: options
}, (err, result) => {
if (err) {
return callback(err)
}
callback(undefined, {value: result})
})
})
}

Expand Down