Random unexplained failed fetch
Unanswered
Highlander posted this in #help-forum
HighlanderOP
I'm sending some data to my backend and for no apparent reason the fetch fails
async function onSubmit(values: z.infer<typeof formSchema>) {
const response = await fetch("http://localhost:8080/user/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
},
body: JSON.stringify({
username: values.username,
password: values.password,
}),
});
if (!response.ok) {
toast({
description: response.json(),
})
}
toast({
description: "Login was successful",
});
}3 Replies
@Dayo what does your route handler file structure look like?
HighlanderOP
turns out it was a cors issue, typical 🤦â€â™‚ï¸