Fix nwc error message (#1417)
* Fix this.error undefined on relay error * Also use arrow function for ws.onmessage
This commit is contained in:
parent
731df5fc67
commit
b4e143460b
|
@ -22,14 +22,14 @@ export class Relay {
|
||||||
constructor (relayUrl) {
|
constructor (relayUrl) {
|
||||||
const ws = new WebSocket(relayUrl)
|
const ws = new WebSocket(relayUrl)
|
||||||
|
|
||||||
ws.onmessage = function (msg) {
|
ws.onmessage = (msg) => {
|
||||||
const [type, notice] = JSON.parse(msg.data)
|
const [type, notice] = JSON.parse(msg.data)
|
||||||
if (type === 'NOTICE') {
|
if (type === 'NOTICE') {
|
||||||
console.log('relay notice:', notice)
|
console.log('relay notice:', notice)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.onerror = function (err) {
|
ws.onerror = (err) => {
|
||||||
console.error('websocket error:', err.message)
|
console.error('websocket error:', err.message)
|
||||||
this.error = err.message
|
this.error = err.message
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue