Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
docs: update readme to use async api
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Jul 11, 2020
1 parent 3fd2ca8 commit c6cd95c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions examples/ipfs-101/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,20 @@ You can learn about the IPFS File API at [interface-ipfs-core](https://github.co

```js
const IPFS = require('ipfs')
const last = require('it-last')

async function main () {
const node = await IPFS.create()
const version = await node.version()

console.log('Version:', version.version)

const filesAdded = await node.add({
const fileAdded = await last(node.add({
path: 'hello.txt',
content: 'Hello World 101'
})
}))

console.log('Added file:', filesAdded[0].path, filesAdded[0].hash)
console.log('Added file:', fileAdded.path, fileAdded.cid)
// ...
}

Expand All @@ -97,22 +98,23 @@ The last step of this tutorial is retrieving the file back using the `cat` 😺

```js
const IPFS = require('ipfs')
const last = require('it-last')

async function main () {
const node = await IPFS.create()
const version = await node.version()

console.log('Version:', version.version)

const filesAdded = await node.add({
const fileAdded = await last(node.add({
path: 'hello.txt',
content: 'Hello World 101'
})
}))

console.log('Added file:', filesAdded[0].path, filesAdded[0].hash)
console.log('Added file:', fileAdded.path, fileAdded.cid)

const chunks = []
for await (const chunk of node.cat(filesAdded[0].hash)) {
for await (const chunk of node.cat(fileAdded.cid)) {
chunks.push(chunk)
}

Expand Down

0 comments on commit c6cd95c

Please sign in to comment.