getting output as promise in line 23
I am trying to fetch the data by using the usereducer of which the dispatcher func is called inside useeffect hook.but i get the output as promise what to do?
let initApi=null;
let apiReducer=async (curdata,perform)=>{
if(perform=='fetch'){
fetchData();
}else{
return null;
}
}
function Cloth() {
let [clothapiData,apiDispatcher]=useReducer(apiReducer,initApi);
useEffect(
()=>{
apiDispatcher('fetch')
}
,[])
console.log(clothapiData);
return (
<div className='cloths'>
{<video autoPlay src='../assets/22.gif'></video>}
{ clothapiData?clothapiData.map(({id,image,title,price})=>{
return <NavLink to={`../../${id}`} className='cloth' key={id}>
<div><img src={image} alt="" /></div>
<h1>{title}</h1>
<h4>₹{price}</h4>
</NavLink>
}): <h1>Loading...</h1> }
</div>
)
}
New contributor
sridhar m is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.