ipfs-http-client
Version:
A client library for the IPFS HTTP API
25 lines (20 loc) • 758 B
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var cid = require('multiformats/cid');
var configure = require('../lib/configure.js');
var toUrlSearchParams = require('../lib/to-url-search-params.js');
const createWantlistForPeer = configure.configure(api => {
async function wantlistForPeer(peerId, options = {}) {
const res = await (await api.post('bitswap/wantlist', {
signal: options.signal,
searchParams: toUrlSearchParams.toUrlSearchParams({
...options,
peer: peerId.toString()
}),
headers: options.headers
})).json();
return (res.Keys || []).map(k => cid.CID.parse(k['/']));
}
return wantlistForPeer;
});
exports.createWantlistForPeer = createWantlistForPeer;