I used fetch API to post sign up user data. Its a simple thing but I don't get it why I am getting internal server error 500 on fetch API, everything seems to work ok with postman problem only arrives when im using react.js to send request
const signupHandler=async(e)=>
{
e.preventDefault();
const formData = new FormData();
formData.append("username" , USERNAME);
formData.append("email" , EMAIL);
formData.append("password" , PASSWORD);
try
{
const response = await fetch('http://localhost:5000/api/users/signup' , {
method : 'POST' ,
body : formData
});
if(!response.ok)
{
throw new Error(response.message);
}
const responseData = await response.json();
console.log(responseData.user)
naviagte("/success");
}
catch(err)
{
setERROR(err.message);
}
Please check the below question, might be of a help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.