Design comparison
SolutionDesign
Solution retrospective
-💡 Added network error notification. -💡 Added rotation to the dice icon on hover.
Community feedback
- @fazzaamiarsoPosted almost 2 years ago
Hi Amos! Great Work!
I have a quick tip for you. You can destructure your response like this.
const handleJoke = () => { setError(""); axios .get("https://api.adviceslip.com/advice") .then((res) => { const { slip : { advice, id }, } = res.data; setAdvice(advice); setAdviceId(id); }) .catch((err) => { const errMessage = err.code === "ERR_NETWORK" ? "Make sure you're connected to the internet" : "Something went wrong"; setError(errMessage); }); };
I hope it helps! Cheers!
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord