diff --git a/README.md b/README.md index 05d7d1c..862e482 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ const codex = new Codex("http://localhost:3000"); To use a module, you need to use the await syntax. If the module is not loaded yet, it will be imported first and then cached in memory. ```js -const marketplace = await codex.marketplace; +const marketplace = await codex.marketplace(); ``` ### Error handling @@ -97,7 +97,11 @@ The following API assume that you have already a marketplace module loaded, exam ```js const codex = new Codex("http://localhost:3000"); +// When using the async api const marketplace = await codex.marketplace(); + +// When using the sync api +const marketplace = codex.marketplace ``` #### activeSlots() @@ -241,7 +245,11 @@ The following API assume that you have already a data module loaded, example: ```js const codex = new Codex("http://localhost:3000"); -const data = await codex.data; +// When using the async api +const data = await codex.data(); + +// When using the sync api +const data = codex.data ``` #### cids @@ -342,7 +350,11 @@ The following API assume that you have already a node module loaded, example: ```js const codex = new Codex("http://localhost:3000"); -const data = await codex.debug; +// When using the async api +const data = await codex.debug(); + +// When using the sync api +const data = codex.debug ``` #### setLogLevel @@ -376,7 +388,11 @@ The following API assume that you have already a node module loaded, example: ```js const codex = new Codex("http://localhost:3000"); -const node = await codex.node; +// When using the async api +const node = await codex.node(); + +// When using the sync api +const node = codex.node ``` #### spr diff --git a/src/data/data.ts b/src/data/data.ts index a20baed..ed67120 100644 --- a/src/data/data.ts +++ b/src/data/data.ts @@ -127,8 +127,8 @@ export class CodexData { } /** - * Download a file from the network in a streaming manner. - * If the file is not available locally, it will be retrieved from other nodes in the network if able. + * Download a file from the network to the local node if it's not available locally. + * Note: Download is performed async. Call can return before download is completed. */ async networkDownload(cid: string): Promise> { const url = this.url + Api.config.prefix + `/data/${cid}/network`;