- 分块传输不触发onChunkReceived
https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/extended/component-plus/uploader.html const requestTask = Taro.request({ url: `${app.chatUrl}/conversation/talk`, method: "POST", enableChunked: true, responseType: "text", data: { prompt: requestQuestion, message_id: uuid(), parent_message_id: uuid(), stream: true, user_id: user_id, }, success: response => { // 开启enableChunked后,成功的回调一般用不到,因为响应数据不在这里返回 console.log(response) } }); console.log(``, requestTask); requestTask.onChunkReceived(function (response) { console.log(1) const arrayBuffer = response.data; const uint8Array = new Uint8Array(arrayBuffer); let text = String.fromCharCode.apply(null, uint8Array); console.log(`text`, text); if (text.trim() === "data: [DONE]") { setLoading(false); return; } const datas = text.split("data:"); datas.shift(); for (let i = 0; i < datas.length; i++) { const part = datas[i]; console.log(`part`, part); const datatxt = part.trim(); if (datatxt === "[DONE]") { setLoading(false); return; } else { const data = JSON.parse(datatxt); setAnswer(data.message.content.parts[0]); } } }); s数据是正常返回的,但是不触发onChunkReceived HTTP/1.1 200 transfer-encoding: chunked transfer-encoding: chunked date: Mon, 17 Jul 2023 10:08:20 GMT for-weapp-devtools: {"transfer-encoding":["chunked","chunked"],"date":["Mon, 17 Jul 2023 10:08:20 GMT"]} z这是返回头
2023-07-17 - wx.request返回值是undefined而不是requestTask?
用taro框架开发的,基础库版本2.32.0,wx.request返回值是undefined而不是requestTask导致不能使用分块传输
2023-07-05