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

Commit 4126a5a

Browse files
vilgacxachingbrain
andauthored
docs: update PUBSUB.md (#3880)
last code wasn't working on line 56. Instead of converting Uint8array to String it was converting the array to string. So instead of text as output , it shows array but with type string. Fixed now with TextDecoder. Working perfectly. Co-authored-by: Alex Potsides <[email protected]>
1 parent 22f462c commit 4126a5a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/core-api/PUBSUB.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ An optional object which may have the following keys:
5353

5454
```JavaScript
5555
const topic = 'fruit-of-the-day'
56-
const receiveMsg = (msg) => console.log(msg.data.toString())
56+
const receiveMsg = (msg) => console.log(new TextDecoder().decode(msg.data))
5757

5858
await ipfs.pubsub.subscribe(topic, receiveMsg)
5959
console.log(`subscribed to ${topic}`)
@@ -203,4 +203,4 @@ console.log(peerIds)
203203
A great source of [examples][] can be found in the tests for this API.
204204

205205
[examples]: https://github.com/ipfs/js-ipfs/blob/master/packages/interface-ipfs-core/src/pubsub
206-
[AbortSignal]: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
206+
[AbortSignal]: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal

0 commit comments

Comments
 (0)