I'm facing some issues with using a fetch post call to pass an object to a method that expects the object. I've created a payload and passed it, but it doesn't seem to be working as expected. I set a breakpoint in the code behind, but it's never triggered. I'm unsure why the fetch call is not functioning properly. Any suggestions on why the endpoint might not be getting reached?
This is my C# method:
[HttpPost]
[Route("ResetPassword")]
private void ResetPassword(Player player) {
}
Javascript:
const continueBtn = document.getElementById("continueBtn");
continueBtn.onclick = () => {
const email = document.getElementById("lblEmail").innerHTML;
sendResetEmail(email);
}
async function sendResetEmail(email) {
const payload = {
email: email
}
const data = new FormData();
data.append("json", JSON.stringify(payload));
let sendResetEmail = await fetch(`/ResetPassword`,
{
method: 'POST',
body: data
});
}