From 57027a5c05f881d38f9c728aebd4ce0a90681001 Mon Sep 17 00:00:00 2001 From: anders Date: Wed, 9 Dec 2020 17:22:29 -0600 Subject: [PATCH] fix examples/keyvalue.js --- examples/keyvalue.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/examples/keyvalue.js b/examples/keyvalue.js index 15e8c1e..8cb1039 100644 --- a/examples/keyvalue.js +++ b/examples/keyvalue.js @@ -23,19 +23,17 @@ const output = (user) => { console.log("Starting...") -const ipfs = new IPFS({ - repo: './orbitdb/examples/ipfs', - start: true, - EXPERIMENTAL: { - pubsub: true, - }, -}) - -ipfs.on('error', (err) => console.error(err)) - -ipfs.on('ready', async () => { +async function main () { let db + try { + const ipfs = await IPFS.create({ + repo: './orbitdb/examples/ipfs', + start: true, + EXPERIMENTAL: { + pubsub: true, + }, + }) const orbitdb = await OrbitDB.createInstance(ipfs, { directory: './orbitdb/examples/keyvalue' }) @@ -65,4 +63,5 @@ ipfs.on('ready', async () => { console.log("Starting update loop...") setInterval(query, 1000) -}) +} +main()