Closed ckpiggy closed 6 years ago
I use
client.send(JSON.stringify({m: 'test'}))
It works
Can you show me the way you defined the route? It should have the json
flag otherwise it takes the data and turns it into a string which results into [object Object]
The route with a json
flag
F.websocket('/', wshandler, ['json']);
You can also stringify it yourself though
controller.all( (c) => {
c.send(JSON.stringify({ m: 'test' }))
})
A Ha! It works! Thank you @molda
When I trying to send JSON to client like
======= 2018-05-12 18:44:29: SyntaxError: Unexpected token o in JSON at position 1 SyntaxError: Unexpected token o in JSON at position 1 at JSON.parse ()
at Framework.F.onParseJSON (/Users/ckpiggy/Documents/Projects/order_online/backend/server/node_modules/total.js/index.js:4991:14)
at WebSocketClient.$decode (/Users/ckpiggy/Documents/Projects/order_online/backend/server/node_modules/total.js/websocketclient.js:442:44)
at /Users/ckpiggy/Documents/Projects/order_online/backend/server/node_modules/total.js/websocketclient.js:485:27
at afterWrite (_stream_writable.js:454:3)
at onwrite (_stream_writable.js:445:7)
at InflateRaw.afterTransform (_stream_transform.js:90:3)
at Zlib.callback (zlib.js:515:5)