I'm relatively new to JavaScript / React.js. I have a random API from which I want to read an item (in this example an email adress).
What if the array has more emails for different users?
In that case, how can I call that specific email, let's say 2nd and 5th. What is the syntax for that?
Code is given bellow:
import {useState,useEffect} from 'react';
function App(){
const url = 'https://randomuser.me/api/';
const [information,setInformation]=useState([]);
async function getData(){
const resp = await fetch(url);
const data = await resp.json();
console.log(data);
const [item]=data.results;
setInformation(item);
}
useEffect(()=>{
getData();
},[])
return(
<>
{information.email}
</>
)
}
export default App;