This is a solution to the Advice generator app challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- View the optimal layout for the app depending on their device's screen size
- See hover states for all interactive elements on the page
- Generate a new piece of advice by clicking the dice icon
- HTML5
- CSS custom properties
- Bootstrap V5.1.3
- Javascript
- Advice Slip API
I haven't done any Javascript app with API before. This one is my first time using API. After this challenge, I learned how to fetch API in Javascript.
const getAdvice = () => fetch('https://api.adviceslip.com/advice')
.then(res => {
return res.json();
})
.then(data => {
console.log(data);
adviceID.textContent = data.slip.id;
adviceText.textContent = data.slip.advice;
})
.catch(error => console.log("ERROR"))
I'll add prograss bar or loading page while the app is waiting for API response.
- Learn Fetch API In 6 Minutes - This helped me to understand how to fetch API in Javascript.