const postSignUpDetails = async (event)=>{
event.preventDefault();
const data = {
firstName : document.getElementById('first_name').value,
lastName : document.getElementById('last_name').value,
email : document.getElementById('email').value,
password : document.getElementById('password').value,
};
console.log(data);
try {
const result = await fetch('http://localhost:3000/api/v1/users/signup',{
method:"POST",
body: JSON.stringify(data),
mode:'no-cors',
headers: {
"Content-Type": "application/json",
// 'Content-Type': 'application/x-www-form-urlencoded',
}
});
console.log(result);
} catch (error) {
console.log(error);
}
}
document.getElementById('sign_up').addEventListener('click',postSignUpDetails);
I am making a post request on my backend server. I am able to see body in request payLoad. But body on the backend is null. payLoad ScreenShot Backend Server Error
Why the request body not reaching on the backend