[Solved] How to get multiple API fetch data avoid first consle.log empty array

To avoid Warn: Possible unhandled Promise Rejection (id:0) useEffect(() => { fetchData(); }, []); async function fetchData(){ try{ const requestArray = await Promise.all(ids?.map((id) => { return fetch(`https://jsonplaceholder.typicode.com/posts/${id}`) .then((response) => response.json()) .then((dataLoc) => { return dataLoc.title; }) .catch((error) => console.error(error)); })); console.log(JSON.stringify(requestArray)); setDataLoc(requestArray); } catch (error) { console.log(error); } } solved How to get multiple API … Read more