fully implemented tanstack query
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { API_BASE } from "../../config/api.config";
|
||||
import type { FormData } from "../../config/interfaces.config";
|
||||
|
||||
export const submitFormData = async (data: FormData, username: string) => {
|
||||
console.warn("submitFormData is fetching!");
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 3000)); // Wait 3 seconds
|
||||
|
||||
const response = await fetch(
|
||||
`${API_BASE}/default/new-entry?username=${username}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.text();
|
||||
throw new Error(error || "Form submission failed");
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
Reference in New Issue
Block a user