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

129
Views
Promise pending issue in React

I try to receive from a helperUtils file, the value that i get in a function. In this function first i call to backend to get some information (this works perfect), then with this value (is an array of data) i do somethings inside te function to return a new value.

When i call this function from my .jsx file and try to receive the final value, i receive Promise in my console when i do a console.log.

function inside Helperutils.js

export const getResponseId = async (idStart) => { 
  const res = await getResponsIdApiNew(idStart);  
  if (res.length === 0) {    
    return (idStart + "1");
  } else {    
    let numbersArray = [];
    for (let j = 0; j < res.length; j++) {      
      if (res[j].substring(idStart.length, res[j].length)[0] !== "") {            
        numbersArray.push(Number(res[j].slice(idStart.length, res[j].length)));           
      }
    }
    if (numbersArray.length !== 0) {         
      const max = Math.max(...numbersArray);              
      let exist = false;
      for (let i = 1; i <= max; i++) {           
        if (!res.includes(idStart + i)) {          
          exist = true;
          idStart = idStart + i;
          console.log(idStart); //give me the value that i want
          break;
        }
      }
      if (exist) {
        console.log(idStart); //give me the value that i want
        return (idStart);
      } else {
        let number = max + 1;
        console.log(idStart + number)     
        return (idStart + number);
      }
    }
  }  
};

in my file.jsx:

i did try:

const getNewIdResponse = async () => {
    await getResponseId(`${getTopic}_${typeResponseTitle}_`);
  };
  console.log(getNewIdResponse);

and try:

const getNewIdResponse = getResponseId(`${getTopic}_${typeResponseTitle}_`);
console.log(getNewIdResponse);

all consoles print:

enter image description here

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!