Create a contact form 7 submission with inbuilt api with the use of javascript

var data = new FormData();
      data.append("FirstName", jQuery('#fname').val());
      data.append("LastName", jQuery('#lname').val());
      data.append("email", jQuery('#email').val());
      data.append("phonenumber", jQuery('#phonenumber').val());

      var xhr = new XMLHttpRequest();
      xhr.withCredentials = true;

      xhr.addEventListener("readystatechange", function() {
        console.log(this.readyState);
        if(this.readyState === 4) {
          console.log(this.responseText);
          data = JSON.parse(this.responseText);
          console.log(data.message);
          $('.error').html(data.message);
        }
      });

//replace 
      xhr.open("POST", "https://www.drjspages.com/wp-json/contact-form-7/v1/contact-forms/1234/feedback");
      xhr.send(data);