ampledata / node-red-contrib-aprs

Node-RED Nodes for connecting to APRS-IS and parsing APRS frames.
Apache License 2.0
9 stars 3 forks source link

Typeof data.data is object not string so if statement never passes #2

Closed mitchmitchell closed 1 year ago

mitchmitchell commented 2 years ago

The code below does not work correctly because the typeof data.data is object not string -- this results in errors from the parser being passed on when the string "# logresp verified, server ..." is received.

ws.onmessage = function(data, flags, number) {
    console.debug(`${new Date().toISOString()} ws.onmessage data.data=${data.data}`);
    node.status({fill: 'blue', shape: 'dot', text: 'Receiving'});
    if (typeof data.data === 'string' && data.data.startsWith('# ')) {
        if (data.data.includes('verified')) {
            node.status({fill: 'green', shape: 'dot', text: 'Connected'});
        }
    } else {
        node.send({'payload': aprs_parser.parse(`${data.data}`)});
    }
};