Hi everyone I’m trying to streamline the ai response and I get this error on my function, anyone have any idea on how to fix it?
let result;
try {
const response = await REQUEST({
method: 'POST',
url: CHATBOT_NEW,
data: data,
auth: true,
});
console.log('+++response.data+++', response.data);
const reader = response?.data?.getReader(); // here is the bug
let chunks = '';
while (true) {
const { done, value } = await reader?.read();
if (done) {
console.log('Completed fetching data');
break;
}
chunks += new TextDecoder('utf-8').decode(value);
}
result = chunks;
} catch (error) {
console.log(error);
}
console.log('+++result+++', result);
return result;
}; ```