react-stomp icon indicating copy to clipboard operation
react-stomp copied to clipboard

TypeError: Cannot read property 'sendMessage' of undefined. Send to/with different topics/msg

Open cazherosu opened this issue 4 years ago • 0 comments

Might be a dumb question, but how do you send messages with different topic and/or msg. I tried doing it in a switch-case, but that resulted in this error.

sendMessage = (messageMap) => { switch (messageMap) { case this.wsGet: this.clientRef.send(this.destinationPrefix + this.wsGet + "/" + this.roomId); break; case this.wsPost: this.clientRef.send(this.destinationPrefix + this.wsPost + "/" + this.roomId, {}, JSON.stringify({ taskName: this.state.taskName, taskDescription: this.state.taskDescription, finished: false })) break; default: console.log("sendMessage case was default...yikes"); break; } };

cazherosu avatar Dec 11 '20 15:12 cazherosu