Reputation: 726
I am new to react-native. I am trying to fetch some data from the API by using fetch but I am not getting any response back or error. Here is the code
useEffect(() => {
fetch("https://randomuser.me/api/?results=8")
.then((res) => res.json().then((data) => console.log(data)))
.catch((err) => console.log(err));
}, []);
What am I doing wrong here??
Upvotes: 0
Views: 800
Reputation: 2068
Seems like your parenthesis ")" is set wrong.
useEffect(() => {
fetch("https://randomuser.me/api/?results=8")
.then((res) => res.json())
.then((data) => console.log(data))
.catch((err) => console.log(err));
}, []);
You should try it like this.
Upvotes: 3