sendSSEMessage(){ fetch( 'http://152.xxx.xx.76:xxxxx/api/v1/chat/message/send?prompt=什么是Python&chat_session_id=1', { headers: { token:"abbb78cbbdde1727ac43bd7770497eee6d598310" } } ).then(response => { const reader = response.body.getReader(); const decoder = new TextDecoder(); function processText({ done, value }) { if (done) { console.log('Stream finished'); return; } console.log(decoder.decode(value)); // data.testData += decoder.decode(value).substring(6) return reader.read().then(processText); } return reader.read().then(processText); }).catch(console.error); },
直接贴代码,被后端教育了,我草了。心态爆照
标签:vue,return,processText,decoder,value,reader,sse,console,链接 From: https://www.cnblogs.com/fanjlqinl/p/17486567.html