[Vuejs]-How to get error message from array buffer

3๐Ÿ‘

โœ…

I finally found the solution I needed here:

let message = String.fromCharCode.apply(
    null, 
    new Uint8Array(errorResponse.body));

However, because Iโ€™m using TypeScript I was getting some kind of annoying message about errorResponse.body not being assignable to type number[], so Iโ€™m doing it like this:

let message = String.fromCharCode.apply(
    null, 
    new Uint8Array(errorResponse.body) as any);

Also note that because my response body had an odd number of characters, I had to use Uint8Array instead of Uint16Array. See this helpful answer for details.

๐Ÿ‘คBassie

Leave a comment