const {
messages: feedbackMessages,
append: requestFeedback,
data: feedbackStream
} = useChat({
id,
api: '/api/feedback',
});
I’ve created my own api endpoint for feedback option ‘api/feedback’ and use append for requesting feedback.
While the ‘feedbackMessages’ return correctly but feedbackStream return ‘undefined’.
What’s going wrong with this?
I want everyone’s help
The issue is likely because useChat from ai/react does not expose a data property by default—data (or feedbackStream in your case) isn’t a valid return key from useChat. Instead, useChat provides properties like messages, append, reload, isLoading, etc. If you’re trying to handle streaming or response content separately, you’ll need to manage that logic within your API handler or modify how you’re consuming the append() response rather than expecting a data field from the hook directly.
Thank you for your help.
I’ve found that the backend only sends datastream when document is created.
(There is a tool for creating document.)