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

Commit f8bd931

Browse files
authored
docs: fix ipfs.cat example (#2968)
Old example was printing an AsyncGenerator object to the console
1 parent 83ca42a commit f8bd931

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/ipfs-101/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,12 @@ async function main () {
111111

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

114-
const fileBuffer = await node.cat(filesAdded[0].hash)
114+
const chunks = []
115+
for await (const chunk of node.cat(filesAdded[0].hash)) {
116+
chunks.push(chunk)
117+
}
115118

116-
console.log('Added file contents:', fileBuffer.toString())
119+
console.log('Added file contents:', Buffer.concat(chunks).toString())
117120
}
118121

119122
main()

0 commit comments

Comments
 (0)