DEV Community

[Comment from a deleted post]
Collapse
 
gorlok profile image
gorlok ๐Ÿง‰ • Edited

Why using Axios when you can use JS's fetch()? Short API GET? Use JS - It's even simpler and without any dependencies.

fetch('api.publicapis.org/entries')
.then(resp => resp.json())
.then(data => data.entries.map((e) => {
let p = document.createElement('p')
let a = document.createElement('a')
p.appendChild(a);
a.setAttribute('href', e.Link)
a.innerHTML = e.API
document.getElementById('data').appendChild(p)
}))

Collapse
 
afpaiva profile image
Andre Paiva

Yes, you are right! It is really shorten.
But the idea of this post is to use Axios as short as I could. So that beginners in Axios, like me), can see how to start using it understanding the minimum usage of it. Like an entry point for study.
Great point, thanks for your comment!