when i am doing like this i got the error
export async function updatePipelineAction(
data: PipelineUpdateFormSchema
): Promise<UpdateResponseSchema> {
const token = cookies().get("token")?.value;
if (!token) {
console.log("No token found, redirecting to login");
redirect("/login");
}
try {
console.log("Sending update request", data);
const response = await ky
.put(`${endpoints.pipeline}?id=${data._id}`, {
headers: {
Authorization: `Bearer ${token}`,
},
json: {
title: data.title,
users: [],
},
})
.json<UpdateResponseSchema>();
console.log("Update response:", response);
return response;
} catch (error) {
console.error("Error in updatePipelineAction:", error);
if (error instanceof HTTPError) {
const errorText = await error.response.text();
console.error("HTTP error response:", errorText);
return {
success: false,
status: error.response.status,
data: "",
message: errorText || "Invalid title",
};
}
return {
success: false,
status: 500,
data: "",
message: "Unexpected error occurred",
};
}
}