To convert the streamed data (which is in binary format) to text, you can use the 'TextDecoder' API. Modify the code as follows:

while (true) {
  const { done, value } = await reader.read();

  if (done) break;

  // convert the binary data to text
  const text = new TextDecoder().decode(value);

  // process the streamed text data here
  console.log(text);
}

This will decode the binary data using the default encoding (which is usually UTF-8) and convert it to a text string. You can then process the text data as needed.

Convert Streamed Binary Data to Text in JavaScript

原文地址: https://www.cveoy.top/t/topic/mluB 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录