Websocket sending blob object instead of string
I had the same issue with an object array. Fixed it by converting the data as a JSON string with JSON.stringify
. On the client, you can get the data with JSON.parse
.
Server
sockets.forEach(w => {
w.send(JSON.stringify(message));
});
Client
connection.onmessage = (message: object) => {
console.log(JSON.parse(message['data']));
}