0

I'm trying to decode a MessagePack response from a backend call using Axios that looks like this: ��matches����attendance��away_team�� etc.

into a format where I can access its contents (e.g. JSON or JavaScript Object). Simply using msgpack-lite's decode doesn't work on it, as it needs to be a Buffer. How can I make this response into a Buffer? As far as I know, a Buffer needs to look like <Buffer 82 a4 6e 61 6d 65 a8 4a 6f 68 6e 20 44 6f 65 a3 61 67 65 0c>

shaotime
  • 39
  • 1
  • 3
  • Buffer.from() – AZ_ Mar 15 '19 at 11:27
  • I do receive a buffer from your answer, but it looks a bit weird. It has "ef bf bd" repeated throughout the Buffer, probably representing the � I would say? I tried to plug the first part of the buffer into http://kawanet.github.io/msgpack-lite/ and see what the answer would be. Buffer.from() resulted in: – shaotime Mar 15 '19 at 12:06
  • If you plug in the first part of the buffer into that website and remove "ef bf bd" from the start then you'll see that it matches my MessagePack Response. However, it makes the characters for JSON/JS Object disappear! – shaotime Mar 15 '19 at 12:07

1 Answers1

0

I solved the issue! I was typing "arrayBuffer" for the responseType header in Axios instead of "arraybuffer" lol

shaotime
  • 39
  • 1
  • 3