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

218
Views
How can I receive the async data as the resolved value?

I'm trying to read files and convert them to a json, then upload them to a server. But I can't seem to be able to get the data back that isn't a promise. Can you point to what I'm doing wrong?

const onSubmit = async (formData: FormValues) => {
    remove();
    append(defaultFormValues.documents[0] as object);
    setIsLoading(true);
    const objToUpload = {
        name: formData.documentName,
        type: formData.documentType,
        contents: [
            formData.documents.map(async (document) => {
                return {
                    language: document.language,
                    data: await readFromFile(document.file[0]),
                    actions: await readFromFile(document.actions[0]),
                };
            }),
        ],
    };
    console.log(objToUpload);
    }
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const onSubmit = async (formData: FormValues) => {
    remove();
    append(defaultFormValues.documents[0] as object);
    setIsLoading(true);

    const data  = await Promise.all(formData.documents.map(async (document) => {
      return {
          language: document.language,
          data: await readFromFile(document.file[0]),
          actions: await readFromFile(document.actions[0]),
      };
    }));

    const objToUpload = {
        name: formData.documentName,
        type: formData.documentType,
        contents: data,
    };
    console.log(objToUpload);
};
about 4 years ago · Juan Pablo Isaza Report
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!