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 Finish

@Adrianocode19

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


What are you most proud of, and what would you do differently next time?

loading icon

What specific areas of your project would you like help with?

Js async

Community feedback

Alex 3,130

@Alex-Archer-I

Posted

Hi!

Basically the async-await pattern and fetch-than chain doing the same thing, it's just different syntax. At first you need to declare function with async keyword. Than you can use await in those parts of the function which must be executed with potential delay.

// Here you declare that this is async function
const fetchAdvice = async () => {

    // Than you use await keyword anytime you need to perform async code.

    // The function will not be executed further till it get the response.
    let response = await fetch('https://api.adviceslip.com/advice');

    // You can perform some code here if need.

    // Here is an analog of this part - .then(response => response.json())
    const advice = await responce.json();

    // And work with advice content.
};

Hope this helps. If you have any questions fell free to ask. Good luck =)

Marked as helpful

1

@Adrianocode19

Posted

@Alex-Archer-I Thank you very much for your help, I'm happy to analyze my code, I had studied asynchronous js but I forgot about await

1
Alex 3,130

@Alex-Archer-I

Posted

@Adrianocode19

Glad I could help =)

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