DEV Community

Discussion on: Axios: My experience with the library.

Collapse
 
jcubic profile image
Jakub T. Jankiewicz • Edited

You're missing the point, axios is almost the same as fetch API and it don't remove those .then() methods. You're using async/await syntax and this is what removes .then(). This have nothing to do with the library. I also think that the library is obsolete after browsers added fetch function. You're adding whole library that do exactly the same what native API do.

Collapse
 
gabrlcj profile image
Gabriel Bittencourt • Edited

Hi thanks for the comment and I my haven't explained well, but what I mean't is that you don't have to code the .then()

Collapse
 
jcubic profile image
Jakub T. Jankiewicz • Edited

Axios is not using async/await. Your code do that and it's JavaScript, the same is with native fetch. async/await is syntax sugar for promises that is not part of Axios it's part of JavaScript. Axios is just using promises it don't uses async/await. So the same will be with any library that use promises.
Here is example of native fetch API:

var res = await fetch('url');
var data = await res.json();
Enter fullscreen mode Exit fullscreen mode

see you also don't need to use .then(), this have nothing to do with axios.

Thread Thread
 
gabrlcj profile image
Gabriel Bittencourt

I see, I appreciate your explanation on the topic!