How to set a cookie that is returned from api call?

I'm using createAsync for a server api call. The api returns data with cookie that I need later.
async function foo(){
"use server";
const res = await callApi();
// how append a cookie here?
return res.data
}
createAsync(()=> foo())
async function foo(){
"use server";
const res = await callApi();
// how append a cookie here?
return res.data
}
createAsync(()=> foo())
I tried appendHeader before return, but I got error Cannot set headers after they are sent to the client.
1 Reply
Antebios
Antebios3w ago
Did you ever solve this error?