// 流式请求
const requestTask = wx.request({
url: "",
enableChunked: true, // 开启流式传输
header: {
'Authorization': token,
"Content-Type": "application/json;charset=UTF-8",
},
method: "post",
responseType: "text",
data: paramData,
timeout: 200000,
success: (res1) => {
console.info("获取成功: ", res1);
_this.scrollToBottom();
},
fail(err) {
console.log(err, "err");
showToast('发送失败,请重试');
},
});
requestTask.onChunkReceived((res) => {
if (res.data) {
let data = new TextDecoder().decode(res.data)
console.log(data)
}
});
requestTask.onHeadersReceived((res) => {
console.log(res)
});
},
fail: function (err) {
}
})