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

Commit b4d1609

Browse files
committed
add produce example for node.js
1 parent af84cd1 commit b4d1609

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// To enable debug logging:
2+
// DEBUG=StreamrClient node examples/node.js
3+
4+
const StreamrClient = require('streamr-client')
5+
6+
const STREAM_ID = 'MY-STREAM-ID'
7+
const API_KEY = 'MY-API-KEY'
8+
9+
// Create the client and give the API key to use by default
10+
const client = new StreamrClient({
11+
restUrl: 'http://localhost:8890/api/v1',
12+
apiKey: API_KEY
13+
})
14+
15+
// Here is the event we'll be sending
16+
const msg = {
17+
hello: 'world',
18+
random: Math.random()
19+
}
20+
21+
// Produce the event to the Stream
22+
client.produceToStream(STREAM_ID, msg)
23+
.then(() => console.log('Sent successfully: ', msg))
24+
.catch((err) => console.error(err))
File renamed without changes.

0 commit comments

Comments
 (0)