Fix nwc error message (#1417)

* Fix this.error undefined on relay error

* Also use arrow function for ws.onmessage
This commit is contained in:
ekzyis 2024-09-19 22:53:42 +02:00 committed by GitHub
parent 731df5fc67
commit b4e143460b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -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
}