How to Handle a Submit for a Form

const postSubmit = (e, title, description, image, category) => {   //prevent the page from refreshing 

const token = localStorage.token;
fetch("*backend link here*", { method: "POST", headers: { "Content-Type": "application/json", },

//stringify your inputs into JSON format
body: JSON.stringify({ userId: userID, title: title, description: description, image: image, category: category, }), })
//after the fetch is done, receive a json response object
.then((response) => response.json())

//set the response data to state inside of react
.then((data) => setData(data)) .catch((err) => {console.log("error posting" + err);});};
<buttontype="submit"onClick={(e) => {handleLogin(e, user, password);}}className="border border-solid rounded-full py-1 px-3 transform translate-y-3 text-white transition-shadow  duration-300 ease-in-out uppercase hover:shadow-lg"style={{ backgroundColor: "#ff9f1c", borderColor: "#ff9f1c" }}>Log in</button>
<form onSubmit={(e) => handleSubmit(e, user, password)}>   //code here 



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store