fetch data
import React, { useState,useEffect } from 'react';
import './Box.css';
function Box() {
const [results, setCount] = useState([]);
async function M1() {
const response = await fetch('https://api.unsplash.com/search/photos?page="+"&query="+cars+"&client_id=HKkVWrW8SC28UJgRPPZ-z0UfJVSH4a7Ym2qoLCa35fY');
const data = await response.json();
setCount(data.results);
console.log(data.results);
}
useEffect(() => {
M1();
},[]);
return (
<div>
<div className="imagess">
{results.map((img)=>{
return(
<>
<span className="imagess">
<img className="imgback" width="400px" height="400px" src={img.urls.small} alt="" srcset="" />
</span>
</>
)
})}
{results.map((img)=>{
return(
<>
<span className="imagess">
<img className="imgback" width="400px" height="400px" src={img.urls.small} alt="" srcset="" />
</span>
</>
)
})}
{results.map((img)=>{
return(
<>
<span className="imagess">
<img className="imgback" width="400px" height="400px" src={img.urls.small} alt="" srcset="" />
</span>
</>
)
})}
</div>
</div>
)
}
export default Box;
Comments
Post a Comment