From e80b37a3d29d1c93a220a3c4ba9d7563ccea83e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bryan=20R=C3=ADos?= Date: Wed, 30 Nov 2022 13:54:42 -0500 Subject: [PATCH] Fix async call to get and put promises --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index fca2365..851faee 100644 --- a/index.js +++ b/index.js @@ -58,7 +58,8 @@ async function read (ipfs, cid, options = {}) { const codec = codecCodes[cid.code] if (!codec) throw unsupportedCodecError() - const bytes = await ipfs.block.get(cid, { timeout: options.timeout }) + const get = (await ipfs).block.get + const bytes = await get(cid, { timeout: options.timeout }) const block = await Block.decode({ bytes, codec, hasher }) if (block.cid.code === dagPb.code) { @@ -95,7 +96,8 @@ async function write (ipfs, format, value, options = {}) { } const block = await Block.encode({ value, codec, hasher }) - await ipfs.block.put(block.bytes, { + const put = (await ipfs).block.put + await put(block.bytes, { cid: block.cid.bytes, version: block.cid.version, format,