Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

547
Views
FormData Returns empty object (React)

My Controller

  public createFinancialDocumentsFilesUpload = ({ document, ...data }: CreateFinancialDocumentsFilesUploadReq) => {
    const formData = new FormData();
    formData.append('document', document);
    console.log(document, 'document');
    console.log('formData', formData);

    return this.requestWithToken<CreateFinancialDocumentsFilesUploadRes>({
      method: 'POST',
      url: FINANCIAL_DOCUMENTS_FILES_UPLOAD,
      data,
    });
  };
}

My handleSubmit

const handleSave = useCallback(
    handleSubmit(async (formData) => {
      const {
        transfer: {
          payment: { sum, expenseType: budgetItemId },
          isRegularPayment: isScheduled,
          invoiceForPayment,
        },
      } = formData;

      await apiCreateDocumentsFilesUpload({ document: invoiceForPayment });
    [],
  );

console.log data can be viewed in image

I am trying to use FormData to send user-entered data in a POST request with the fetch API. The problem is that when I create a new FormData object with the form that I've created, it keeps creating an empty object - no entries/keys/valuesenter image description here

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!