BackendSupabase
Problem
When trying to implement the new task function
export async function task(task: string, parent: string) {
const { error } = await supabase.from("Tasks")
.insert({ task: task, parent: parent })
if (error) {
console.error("Error in Creating New Task",
error.message);
return false;
} else {
return true;
}
}It complained below.
Error in Creating New Task insert or update on table "Tasks"
violates foreign key constraint "Tasks_parent_fkey"
Body is unusable: Body has already been readReflection
Violating foreign key constraint
Need to make sure the provided value can be found in referred column.
Body is unusable
It's found the form post handling called twice, by component as well as the page.
if (Astro.request.method === "POST") {
const data = await Astro.request.formData();
const action = data.get("action");
const stack = data.get("stack");
await create(String(action), String(stack));
}