Closed lapwat closed 3 years ago
In the onResponse hook, response.body is a ReadableStream, how to decode it ?
$http.onResponse((req, options, res) => { console.log('Response data :', res.body) });
Response data : ReadableStream {locked: false}
I tried to read the stream but I get a byte array.
$http.onResponse(async (req, options, response) => { console.log('Response data :', await response.body.getReader().read()) });
Response data : {value: Uint8Array(296), done: false}
Found the solution:
$http.onResponse(async (req, options, response) => { console.log('Response data :', await response.json()) })
Response data : { myAttr: "myValue" }
In the onResponse hook, response.body is a ReadableStream, how to decode it ?
I tried to read the stream but I get a byte array.