How do response.send a TypedArray?


I’m trying to send a short typed array in response.send. It keeps being serialised to JSON



If you use response.send() then it is the same as if you call response.json().



Then, how do I send anything without serialising it or turning it into a string?



Not sure but maybe you could use something like this:

  data: myArray

On the client side you can cast data from string to array.



This is not an option for me.

I decided to simply use response.write while using a setInterval for now.



Http doesn’t have data types, it’s all text. Data types exists in a programming language and not at the HTTP transport layer.

What you need to do is send binary data as response and handling of binary data depends upon the client making the request. If you are making an Ajax request, then it will be handled differently and if you are making request from native platform like Android, then it will be handled differently.

So please share more info

1 Like


The client is written in C and is more than a decade old. I can’t change anything on its side. So the format of data sent will stay the same. It has to be raw bytes without string conversion.

Converting binary data to a string is a not a valid option in JS. Unlike PHP or some other languages, a string to byte value and reverse conversion in JS may not go 1-to-1.