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

Responsive API call display app

kiantpetersenβ€’ 210

@kiantpetersen

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


Made this API call and display with API. I used the setInterval function so that new data is called and displayed. An issue I am having is that if a leave the page and return, the API call does not obey the set Interval. Please let me know how I can fix this issue. I also used the useEffect function to make the API call on the initial load. Please let me know how I can improve this component and make it more efficient.

Community feedback

Md5 daltonβ€’ 1,430

@md5dalton

Posted

Hi thereπŸ‘‹

The idea is to generate a new piece of advice by clicking the dice icon so you don't need to use a timer. So you just attach a click listener on the dice icon like so:

<div className='quote-dice' onClick={() => getAdvice()}>...</div>

You can even go further by handling loading and error states. πŸ‘

Marked as helpful

1

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