fix readme example.

fixes https://github.com/nbd-wtf/nostr-tools/issues/136
This commit is contained in:
fiatjaf
2023-02-27 12:43:23 -03:00
parent 9d345a8f01
commit a4c713efcb

View File

@@ -10,7 +10,6 @@ Only depends on _@scure_ and _@noble_ packages.
npm install nostr-tools # or yarn add nostr-tools npm install nostr-tools # or yarn add nostr-tools
``` ```
## Usage ## Usage
### Generating a private key and a public key ### Generating a private key and a public key
@@ -138,11 +137,16 @@ const pool = new SimplePool()
let relays = ['wss://relay.example.com', 'wss://relay.example2.com'] let relays = ['wss://relay.example.com', 'wss://relay.example2.com']
let relay = await pool.ensureRelay('wss://relay.example3.com') let sub = pool.sub(
[...relays, 'wss://relay.example3.com'],
let sub = pool.sub([...relays, relay], [{ [
authors: ['32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245'] {
}]) authors: [
'32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245'
]
}
]
)
sub.on('event', event => { sub.on('event', event => {
// this will only be called once the first time the event is received // this will only be called once the first time the event is received