const url = "https://randomuser.me/api";
const userData = async () => {
fetch(url)
.then((response) => {
if (response.status === 200) {
return response.json();
} else {
throw new Error("Something went wrong");
}
})
.then((data) => {
const users = data.results;
// console.log(users);
setData(users);
})
.catch((error) => {
console.log(error);
});
};
useEffect(() async => {
const data = await userData();
}, []);