如果不用流式,打印出来是正常的。 [图片]
wx.request流式字符乱码问题这里怎么转字符都会乱码 但是用postman请求就没一点儿问题 const requestTask = wx.request({ url: 'https://ark.cn-beijing.volces.com/api/v3/bots/chat/completions', method: 'POST', enableChunked: true, responseType: "arraybuffer", // 以 ArrayBuffer 格式接收数据 data: { "model": '', "messages": [{ "role": "user", "content": "写一个文章" }], "stream": true, }, header: { 'content-type': 'application/json', 'Authorization': 'Bearer xxx' }, success: response => {}, fail: error => {} }); requestTask.onChunkReceived((response) => { const arrayBuffer = response.data; const uint8Array = new Uint8Array(arrayBuffer); const str = new TextDecoder('utf-8').decode(uint8Array); console.log('str:',str) }); [图片]
2天前