in onClick, I call the function and use preventDefault() but the web page is refreshed. I'm not sure if it about's axios because when it done to fetching the web page is refreshes immediately.
function submit(event){
event.preventDefault();
const formData = new FormData();
formData.append("name", name);
axios({
method: "POST",
url: "http://localhost:5000/insert-data",
headers: {"Content-Type": "multipart/form-data"},
data: formData,
onUploadProgress: (e)=>{
if(e.lengthComputable){
console.log(((e.loaded * 100 / e.total)+"").split(".")[0])
}
}
}).then(res=>{
console.log(res.data);
})
form
<input type="text" placeholder="name" onChange={e=>setName(e.target.value)} /> <br />
<input type="file" onChange={e=>setVideo(e.target.files[0])} /> <br />
<button type="button" onClick={submit}>Insert Data</button>
Try if adding a form tag solves this issue