doc: fix order of commands to connect to relay

This commit is contained in:
Roland Bewick
2023-02-16 20:53:52 +07:00
committed by fiatjaf
parent 3a22dd3da6
commit f9748d9cc3

View File

@@ -60,8 +60,6 @@ import {
} from 'nostr-tools' } from 'nostr-tools'
const relay = relayInit('wss://relay.example.com') const relay = relayInit('wss://relay.example.com')
await relay.connect()
relay.on('connect', () => { relay.on('connect', () => {
console.log(`connected to ${relay.url}`) console.log(`connected to ${relay.url}`)
}) })
@@ -69,6 +67,8 @@ relay.on('error', () => {
console.log(`failed to connect to ${relay.url}`) console.log(`failed to connect to ${relay.url}`)
}) })
await relay.connect()
// let's query for an event that exists // let's query for an event that exists
let sub = relay.sub([ let sub = relay.sub([
{ {