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

123
Views
Will nesting async functions negatively affect performance?

I am working on a form submit and want to get the tokens on submit, because if I get them on page load load they might expire before use.

function handleSubmit(e) {
    e.preventDefault();

    async function getTokens() {
      return axios
        .get("example.com/get-token/306/")
        .then((response) => {
          return response.data;
        });
    }
    getTokens().then((data) => {
      async function submitForm() {
        const formData = new FormData();
        formData.append("token", data.message);
        formData.append("session", data.session);
        formData.append("email", email.current.value);

        const res = await axios.post(
          "https://example.com/submit/306/",
          formData,
          {
            headers: { "Content-Type": "multipart/form-data" },
          }
        );
      }
      submitForm();
    });
  }

Will this significantly decrease performance? The other method I tried is saving the tokens with setState on page load, but as I said this risks them expiring before use.

about 4 years ago · Juan Pablo Isaza
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!