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

182
Views
Async/await - cannot reach promise result

I am trying to reach the Promise result in a Reactjs function component, but it does not work for me. When I return the function result I only get Promise. My goal is to return an object contained in [[Promise Result]].

const params = ['ACT', 'STBY', 'STBYH'];
const getActStby = async address => {
  const getActStbyParams = await getXhr({
    url: `./scripts/system_read_config?${xhrParam(address, params)}`
  });
  return getActStbyParams;
};

Then I call It later in a code and assigning to the object as a new property:

newItemEqpt.isAct = getActStby(getNetworkAddress(item.from.FROM, item.to.TO));

Output of these activities is "partially" okay. When I console.log the object, Promise is fulfilled, but what I wanted to is assigning the array of parameters in [[Promise result]] directly to isAct property. How can I do this?

isAct: Promise
 [[Prototype]]: Promise
 [[PromiseState]]: "fulfilled"
 [[PromiseResult]]: Object
   parameters: (3) [{…}, {…}, {…}]
   [[Prototype]]: Object
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The function getActStby declared as async, so you have to await for getting its results like so;

newItemEqpt.isAct = await getActStby(getNetworkAddress(item.from.FROM, item.to.TO));

To be able to use the await keyword like above, the function call to getActStby should also be made in an async function, otherwise you will have to chain the function with a then method and access the return value of that function by using a callback.

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!