Skip to content
This repository has been archived by the owner on Sep 30, 2023. It is now read-only.

Commit

Permalink
update code snippets to support js-ipfs >= 0.38
Browse files Browse the repository at this point in the history
Updated code snippets to support js-ipfs >= 0.38
  • Loading branch information
vasa-develop committed Apr 5, 2020
1 parent e5957d1 commit 97df5c0
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions README.md
Expand Up @@ -92,19 +92,24 @@ npm install ipfs-log ipfs
Run a simple program:

```javascript
const IPFS = require('ipfs')
const Log = require('ipfs-log')
const IdentityProvider = require('orbit-db-identity-provider')

const identity = await IdentityProvider.createIdentity({ id: 'peerid' })
const ipfs = new IPFS()
const log = new Log(ipfs, identity)

ipfs.on('ready' , async () => {
await log.append({ some: 'data' })
await log.append('text'))
console.log(log.values.map(e => e.payload))
})

// For js-ipfs >= 0.38

const Log = require("ipfs-log");
const IdentityProvider = require("orbit-db-identity-provider");
const IPFS = require("ipfs");

const start = async () => {
const identity = await IdentityProvider.createIdentity({ id: "peerid" });
const ipfs = await IPFS.create({ repo: "./path-for-js-ipfs-repo" });
const log = new Log(ipfs, identity);

await log.append({ some: "data" });
await log.append("text");
console.log(log.values.map((e) => e.payload));
};

start();

// [ { some: 'data' }, 'text' ]
```
Expand Down

0 comments on commit 97df5c0

Please sign in to comment.