Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Advice generator app

@SoulRvr29

Desktop design screenshot for the Advice generator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
  • API
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


It was easy, but a good challenge. It's the first time I've combined React with Tailwind and I'm happy with the result. I'm still not entirely sure how data fetch works, but I managed to get it done.

Community feedback

@fazzaamiarso

Posted

Hi @SoulRvr29! Great work on your project, the README is fantastic!

You can use 1 state for this project. Example

// `advice` become an object
const [advice, setAdvice] = useState({});

// then you can get the advice data
const adviceContent = advice.advice;
const adviceId = advice.id

  useEffect(() => {
    clickHandler();
  }, []);

  const clickHandler = () => {
    fetch("https://api.adviceslip.com/advice")
      .then((response) => {
        if (response.ok) {
          return response.json();
        } else {
          console.log("no data");
        }
      })

      .then((data) => {
        setAdvice(data.slip)
      })

      .catch((err) => {
        console.log("Something went wrong!", err);
      });
  };

I hope it helps! Cheers!

Marked as helpful

1

@SoulRvr29

Posted

@fazzaamiarso You're right, I changed the code. Thanks for the help.

0

@KeoLamola

Posted

Hi @SoulRvr29 great work I must say. I m really inspired by your work, honestly do. Keep up the good work, I m learning so much from your journey. #cheers

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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