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

168
Views
Using fetch with async/await inside useEffect returns the data but the data is empty when called inside a component

I'm trying to fetch data from a mock JSON server using async/await inside useEffect and the data fetched is stored in a variable (Items) with useState. But I seem to have difficulty of using that data on a component (Content.js). the problem is when I console.log the variable to check for the fetched data inside App.js file I can see the data, but when I console.log the same variable inside the component, it returns [object Object],[object Object],[object Object],[object Object],[object Object]

function App() {
const API_URL = 'http://localhost:3500/Items';

const [Items, setItems] = useState([]);

console.log(Items)

useEffect(()=>{
const fetchItems = async () =>{
  try{
    const response = await fetch(API_URL);
    const listedItems = await response.json();

    console.log(listedItems);
    setItems(listedItems);
  }
  catch(err){ 
    console.log(err.message)
  }
}

  (async () => await fetchItems())();
}, []) 

return (
  <div>
    <Content
       Items = {Items}
     />
  
  </div>
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!