如何将FormData中的数据发送到api?

How to send data in FormData to api?

我想将数据作为 FormData 发送到 Api 我使用 react react-hook-form 这就是我所拥有的:

const submitForm = (data) => {
    console.log(data)==>{Title:"test" ,Countent:"countent"} 
    service.uploadFile(data, (status, result) => {
      if (result.Success) {
        props.notifySuccess(result.Message);
      } else {
        props.notifyError(result.Message);
      }
    });
  };

如何将数据作为 FormData 发送?

const submitForm = (data) => {
     const formData = new FormData();
    Object.keys(data).forEach((ele) => formData.append(ele, data[ele]))
    service.uploadFile(formData, (status, result) => {
      if (result.Success) {
        props.notifySuccess(result.Message);
      } else {
        props.notifyError(result.Message);
      }
    });
  };