Skip to content
This repository was archived by the owner on Sep 28, 2021. It is now read-only.

Commit 8828822

Browse files
Pedro Santosvasco-santos
Pedro Santos
authored andcommitted
chore: update readme to use async/await syntax (#29)
1 parent ae6d61e commit 8828822

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ This project creates a HTTP response for an IPFS Path. This response can be a fi
2626
```js
2727
const { getResponse } = require('ipfs-http-response')
2828

29-
getResponse(ipfsNode, ipfsPath)
30-
.then((result) => {
31-
...
32-
})
29+
(async () => {
30+
const result = await getResponse(ipfsNode, ipfsPath)
31+
console.log(result)
32+
})()
3333
```
3434

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

42-
resolver.cid(ipfsNode, ipfsPath)
43-
.then((result) => {
44-
...
45-
})
42+
(async () => {
43+
const result = await resolver.cid(ipfsNode, ipfsPath)
44+
console.log(result)
45+
})()
4646
```
4747

4848
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`:
@@ -51,10 +51,10 @@ If `ipfsPath` points at a directory, `resolver.cid` will throw Error `This dag n
5151
```js
5252
const { resolver } = require('ipfs-http-response')
5353

54-
resolver.directory(ipfsNode, ipfsPath, cid)
55-
.then((result) => {
56-
...
57-
})
54+
(async () => {
55+
const result = await resolver.directory(ipfsNode, ipfsPath, cid)
56+
console.log(result)
57+
})()
5858
```
5959

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

0 commit comments

Comments
 (0)