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:
- Generate a random advice by pressing a dice button
- Live Site URL: Advice Generator App
- Semantic HTML5 markup
- JavaScript
- API Consuming
- Flexbox
- Position relative & absolute
- Mobile-first workflow
This advice app helped me to understand a little bit about how to consume API.
There are a lot of ways you can do it. In my case, to this project I used Axios CDN, you can see more here Axios.
Here some code:
<body>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</body>
const URL = 'https://api.adviceslip.com/'
function getAdvice() {
axios
.get(url)
.then((response) => console.log(response)) // success!
.catch((error) => console.log(error)) // error!
}
- Advice Slip JSON API - This API helped me to make the app. It's pretty simple to use, no complications.
- LinkedIn - matheus.lincon.10010
- Frontend Mentor - @matheus-lincon