# Nakama Socket.sendmatchstate receives data as a uint8array(15)

**URL:** https://forum.heroiclabs.com/t/nakama-socket-sendmatchstate-receives-data-as-a-uint8array-15/2830
**Category:** Runtime Framework
**Created:** [July 14, 2022, 1:48am UTC](https://forum.heroiclabs.com/t/nakama-socket-sendmatchstate-receives-data-as-a-uint8array-15/2830 "2022-07-14T01:48:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![alex1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/alex1/32/1237_2.png) [@alex1](https://forum.heroiclabs.com/u/alex1)
#### Post date: [July 14, 2022, 1:48am UTC](https://forum.heroiclabs.com/t/nakama-socket-sendmatchstate-receives-data-as-a-uint8array-15/2830/1 "2022-07-14T01:48:32Z")

</div>

Hello, I am trying to make a multiplayer game where a client can send their x and y position to other clients in the match. To test, I tried to send the coordinates (0, 0) first.

Here is the code I use to send data.

let data = {x: 0, y: 0}  
socket.sendMatchState(matchID, OpCodes.position, data);

I connected another client to the same match and it received the data successfully, however, when I am trying to access the data variable I get a uint8array, not the original data object {x: 0, y: 0}.

Here is the code for the listener:  
socket.onmatchdata = (result) =\> {  
switch (result.op\_code) {  
case OpCodes.position: {  
console.log(result);  
movePlayer(result.presence.user\_id, result.data);  
}  
break;  
}  
}

When I console log the result object, here is what is displayed:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/2X/d/da2445b492f672ef01a3db78a46570149f7c8101.png)

Is there any way to get the coordinates sent by the original client? Thanks!

---

<div class="post-metadata">

### Author: ![flavio](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/flavio/32/2161_2.png) [@flavio](https://forum.heroiclabs.com/u/flavio)
#### Post date: [July 14, 2022, 9:18am UTC](https://forum.heroiclabs.com/t/nakama-socket-sendmatchstate-receives-data-as-a-uint8array-15/2830/2 "2022-07-14T09:18:57Z")

</div>

Hi alex1,

You should pass the data as a string, using `JSON.stringify` and then use the inverse function to get back the structure.

Out of curiosity, if you use `String.fromCharCode` with the byte array you got, you will see that it will print `"[object Object]" ` (the usual javascript serialization of objects to strings)

![Screenshot 2022-07-14 at 10.00.17](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/2X/e/ec6f596efb0740c3c0b2dae48ed2333b70a0a3ec.png)

---

<div class="post-metadata">

### Author: ![lugehorsam](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/lugehorsam/32/314_2.png) [@lugehorsam](https://forum.heroiclabs.com/u/lugehorsam)
#### Post date: [July 14, 2022, 8:50pm UTC](https://forum.heroiclabs.com/t/nakama-socket-sendmatchstate-receives-data-as-a-uint8array-15/2830/3 "2022-07-14T20:50:46Z")

</div>

@alex1 before you `JSON.parse` the payload you should decode it with `TextDecoder`
