From b4e143460baf7c6ad616ff8a8515c609d095930a Mon Sep 17 00:00:00 2001 From: ekzyis Date: Thu, 19 Sep 2024 22:53:42 +0200 Subject: [PATCH] Fix nwc error message (#1417) * Fix this.error undefined on relay error * Also use arrow function for ws.onmessage --- lib/nostr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nostr.js b/lib/nostr.js index b61ae304..7a5e497a 100644 --- a/lib/nostr.js +++ b/lib/nostr.js @@ -22,14 +22,14 @@ export class Relay { constructor (relayUrl) { const ws = new WebSocket(relayUrl) - ws.onmessage = function (msg) { + ws.onmessage = (msg) => { const [type, notice] = JSON.parse(msg.data) if (type === 'NOTICE') { console.log('relay notice:', notice) } } - ws.onerror = function (err) { + ws.onerror = (err) => { console.error('websocket error:', err.message) this.error = err.message }