I have a csv file that I want to convert and upload to my local json server I have tried this code using papaparse
const handleSubmit = () => {
    for (let i = 0; i < data.length; i++) {
      let exactData = data[i].data;
      let phone = exactData[0];
      let lastname = exactData[1];
      let firstname = exactData[2];
      let email = exactData[3];
      let CSVData = {
        phone: phone,
        lastname: lastname,
        firstname: firstname,
        email: email,
      };
      fetch("http://localhost:8000/subm", {
        method: "POST",
        headers: { "content-Type": "application/json" },
        body: JSON.stringify(CSVData),
      })
        .then((response) => response.json())
        .then((data) => {
          alert("new users added");
         
        });
    }
  };
Is there a better way of doing this?
 
     
    