Design comparison
Solution retrospective
Any feedback welcome
Community feedback
- @i-am-KhaelPosted over 2 years ago
Great effort..
You can use this API endpoint https://api.adviceslip.com/advice/{id}, and generate a random number to replace id.. so that every time a user clicks on dice icon it will generate a random advice base on the id.. You can refer to my solution, https://www.frontendmentor.io/solutions/advice-generator-app-using-html5-css3-and-vanilla-js-S1-ZYT7Q5
Marked as helpful1@karolbanatPosted over 2 years ago@i-am-Khael Thanks for the advice. Actually I thought about using your solution, because in my solution generating random advice doesn't work for example in Firefox. And after you commented I searched for solution and found it's problem with caching ( adding { cache: 'no-cache' } to fetch method solves the problem ). Again, really thank you, because thanks to you I found a solution :)
1 - @Deevyn9Posted over 2 years ago
Great representation, Adjusting the height and width of the dice for the mobile view would be great. Happy coding
1@karolbanatPosted over 2 years ago@Deevyn9 Thanks for the comment. I left the size for mobile and desktop view the same, because in design preview they looked for me the same.
1 - @dostonnabotovPosted over 2 years ago
Hi, bro. I am just wondering how did you do that? I mean, js stuff. I review your code, but have no idea how API works.
1@karolbanatPosted over 2 years ago@dostonnabotov Hi again :) As for how API works, I use MDN docs (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). I'll try to explain (although I'm not good at explaining things):
- the fetch part ask the site for response
- then the response is converted to JSON object
- and then I extract data I need For what's in response I get I use the advice API documentation and console.log in browser. Then I just search for data I need and use it. In short, working with API is actually working with documentation. I hope I helped somehow.
1
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