Design comparison
SolutionDesign
Solution retrospective
This is great challange for me it teach me many thing about api but i want to know more about api
- Why the global variable isn't store the api data from fetch() function. (I am trying to store api data in globle variable as well as in object also but I am faild again and again and after 2 hour of hard work I am give up ) and make a function called show() which takes data as a parameter
Community feedback
- @lipe11Posted over 2 years ago
hi, if you want to store the data in a global variable, and then assign it to DOM elements, you could try something like this:
let slip = {} // global variable function getdata() { fetch(url) .then(response => response.json()) .then(data => { slip = data.slip // assign to global variable return slip // pass data to the next "then" }) .then(slip => { id.innerHTML = slip.id advice.innerHTML = slip.advice }) }
but having the data in a global variable might not be that useful in this case, instead you can omit it like this:
function getData() { fetch(url) .then(response => response.json()) .then(data => data.slip) .then(slip => { id.innerHTML = slip.id advice.innerHTML = slip.advice }) }
Marked as helpful0 - @besttlookkPosted over 2 years ago
HI, Great work. Three thinks i like to point out.
- Shadow for hover state of button is too much.
- Everythings looks responsive appart from divider. Somethings it comes out of the box.
- Footer you added at the bottom is too small.
Good Luck, #happyCoding
Marked as helpful0
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