Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧐[问题] 初始化组件的时候, 希望能调服务的API, 展示一次value. 用initialChats异步没有生效 #328

Closed
sds1037681793 opened this issue Oct 28, 2024 · 2 comments

Comments

@sds1037681793
Copy link

🧐 问题描述

💻 示例代码

🚑 其他信息

@sds1037681793
Copy link
Author

    initialChats={initChats}  useEffect(() => {
initFn()

}, []);
const initFn=async()=>{
const content = [{
type: 'text',
text: {
value: 【${parentHref}】
}
}]
const response = await fetch('/health/bella', {
method: 'POST',
body: JSON.stringify({ content: content }),
headers: {
'Content-Type': 'application/json',
}
});
const data = await response.json();
console.log(data.data?.data?.content?.[0].text?.value,'====')
setInitChats({
Sb5pAzLL: {
content: data.data?.data?.content?.[0].text?.value,
id: 'Sb5pAzLL',
role: 'assistant',
}
})
}

@sds1037681793
Copy link
Author

setChats

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant