Hello, I'm new to sveltekit and I am trying to fetch post data in sveltekit using a POST request.
Currently, I am utilizing axios to send the post data.
const request = await axios
.post("/api/user", {
username,
email,
password,
repassword
})
.then((response) => {
console.log(response)
})
.catch((error) => {
console.error(error);
});
Below is my POST Endpoint:
// src/routes/user/+server.ts
export const POST = async({request}) => {
console.log(request)
return new Response(JSON.stringify({something: 1}))
}
This API functions well with GET methods.