Skip to content

fix: passed GetOptions to getJSONData #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: ipfs-v15
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@
},
"dependencies": {
"ipfs-core": "0.14.3"
},
"peerDependencies": {
"ipfs-core-types": "^0.10.3"
}
}
5 changes: 3 additions & 2 deletions src/ipfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
*/
import type { Options, IPFS, CID } from 'ipfs-core';
import type { GetOptions } from 'ipfs-core-types/types/src/dag';
import { IPFSInterface } from './types';

const defaultIpfsConfig: Options = {
Expand Down Expand Up @@ -130,11 +131,11 @@ function createIPFSInterface(bootstrapNodes: string[], ipfsConfig: Options = def
return Buffer.concat(content).toString();
};

const getJSONData = async <T>(cid: string) => {
const getJSONData = async <T>(cid: string, options?: GetOptions) => {
if (!node || !CIDClass) {
throw new Error(`Not initialised!`);
}
const res = await node.dag.get(CIDClass.parse(cid));
const res = await node.dag.get(CIDClass.parse(cid), options);
if (!res.value) {
throw new Error(`No data found!`);
}
Expand Down