I have a problem sending an array from backend js to the client side.
I tried the following on the server side:
for (var i=0; i < clients.length; i++) {
clients[i].send(clients);
}
for (var i=0; i < clients.length; i++) {
clients[i].send(JSON.stringify(clients));
}
- also using json.stringify on the client side as well
for (var i=0; i < clients.length; i++) {
clients[i].send(clients.join('\n')));
}
- I also tried this method on the client side.
Unfortunately, none of the above solutions worked. The JSON.stringify method obviously did not work on the server, since JSON.stringify is a browser, however other methods returned either [object Object], or"[object Object]"
How can I send an array clientsto the client side, or even if I can encode it in JSON, and then send it and parse on the client side.
In fact, all I need is to send the content to the client side, but I don’t know how to do it. haha
Any ideas are welcome :)