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

Commit

Permalink
chore: update readme to use async/await syntax (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Santos authored and vasco-santos committed Oct 14, 2019
1 parent ae6d61e commit 8828822
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ This project creates a HTTP response for an IPFS Path. This response can be a fi
```js
const { getResponse } = require('ipfs-http-response')

getResponse(ipfsNode, ipfsPath)
.then((result) => {
...
})
(async () => {
const result = await getResponse(ipfsNode, ipfsPath)
console.log(result)
})()
```

### Using protocol-agnostic resolver
Expand All @@ -39,10 +39,10 @@ This module also exports the used ipfs `resolver`, which should be used when the
```js
const { resolver } = require('ipfs-http-response')

resolver.cid(ipfsNode, ipfsPath)
.then((result) => {
...
})
(async () => {
const result = await resolver.cid(ipfsNode, ipfsPath)
console.log(result)
})()
```

If `ipfsPath` points at a directory, `resolver.cid` will throw Error `This dag node is a directory` with a `cid` attribute that can be passed to `resolver.directory`:
Expand All @@ -51,10 +51,10 @@ If `ipfsPath` points at a directory, `resolver.cid` will throw Error `This dag n
```js
const { resolver } = require('ipfs-http-response')

resolver.directory(ipfsNode, ipfsPath, cid)
.then((result) => {
...
})
(async () => {
const result = await resolver.directory(ipfsNode, ipfsPath, cid)
console.log(result)
})()
```

`result` will be either a `string` with HTML directory listing or an array with CIDs of `index` pages present in inspected directory.
Expand Down

0 comments on commit 8828822

Please sign in to comment.