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

191
Views
Why API call no longer works since a refactor?

I made this useEffect code that works good in a screen:

 useEffect(() => {
    getDatasFromId(searchId)
        .then((data) => {
            const returnObject = {
                next: data.next,
                items: data.results.map(item => ({ name: item.name, url: item.url }))
            };
            setHasNext(returnObject.next);
            setDataToDisplay(returnObject.items);
        });
}, [searchId]);

But now, I made some modification and the API call is running without return (no error or whatever). My new code is this:

useEffect(() => {
    const apiUrl = getApiUrl(searchId);
    console.log("API URL : ", apiUrl);
    getDatas(apiUrl)
        .then((data) => {
            console.log("We get some data : ", data.results );
            const returnObject = buildDataObject(data);
            console.log("returnObject : ", returnObject);

            setDataToDisplay(returnObject.items);
            returnObject.next !== null && loadMoreApiDatasIf(returnObject.next);
        });
}, [searchId]);

I don't see the error in the new code.

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!