Search code examples
node.jsjsonwebsockettabris-js

tabris.js websocket cant recive anything but a string


I am trying very hard and losing my patience with trying to send a simple array across to tabris.js

using this ws.send(JSON.stringify(["friendArray",{data: results}])) i have to stringify it or it just crashes my tabris app for no reason but when i go to JSON.parse() it. it keeps just giveing me an error Unexpected token 1 in JSON at psotion 0

I'm honestly at a loss I don't know what I could be doing wrong it could be something super simple but I'm frying my brain just trying to come up with a way to transport this simple information could someone please point me in the right direction


Solution

  • try something like, I assume results is some kind of variable, you just need to put data key in double quotes.

    JSON.stringify(["friendArray",{data: results}])
    

    to -

    JSON.stringify(["friendArray",{"data": results}])