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

Commit

Permalink
docs: update PUBSUB.md (#3880)
Browse files Browse the repository at this point in the history
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 <alex@achingbrain.net>
  • Loading branch information
vilgacx and achingbrain authored Sep 21, 2021
1 parent 22f462c commit 4126a5a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/core-api/PUBSUB.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ An optional object which may have the following keys:

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

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

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

0 comments on commit 4126a5a

Please sign in to comment.