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 solution

Lucian 120

@iflucian

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


A nice way to practice and interact with 3rd-party APIs.

Any suggestions, tips or advice :) for improving the code are always welcome.

Thank you!

Community feedback

@YerikAH

Posted

Hello!! 👋

You can add this:

const response= await fetch(urlAPI, {
    method: "GET",
    cache: "no cache",
  }); 

The above code is so that it does not cache the tips, it seems that when I click on the button it only gives me a tip. Although this can also be solved by changing the url to https://api.adviceslip.com/advice/${id}, and for each request they can change the id with a random number.

You can also implement an error handler, in case there is an error in the API.

  try {
    const response = await fetch(urlAPI, {
      method: "GET",
      cache: "no-cache",
    });
    if(!response.ok){
      throw {
        // 
      }
    }
  } catch (err) {
    // 
  }

Hope am helpful.

Good job for completing this challenge.

Marked as helpful

0

Lucian 120

@iflucian

Posted

@YerikAH

Hello, Yerik!

I appreciate your advice and give it a try.

Thanks!

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