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

324
Views
How to set variables after async function call returns

How to set variables after async function call returns?

const fetch = async () => {
  await function_here { ... }
};

const {
    data: mintData,
    write: mint,
    isLoading: isMintLoading,
    isSuccess: isMintStarted,
  } = useContractWrite(contractConfig, 'mint', {
      args: [ARGS_FROM_ASYNC_FETCH_CALL_HERE],
});

I tried doing

const {
    data: mintData,
    write: mint,
    isLoading: isMintLoading,
    isSuccess: isMintStarted,
  } = fetch().then((result) => useContractWrite(contractConfig, 'mint', {
 args: [result],
}));

However, that didn't work due to "Hooks can only be called inside of the body of a function component." How am I supposed to populate ARGS_FROM_ASYNC_FETCH_CALL_HERE from the async function if I can't chain promises?

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!