Which is better? Axios or Fetch?
Javico11

Javico11 @javicodev11

Joined:
Aug 2, 2022

Which is better? Axios or Fetch?

Publish Date: Apr 5 '23
1 2

Personally, I like the simplicity of both, but I use more Axios, I would like to know your opinions about it.
I attach an example of the basic use of Axios:

const fetchData = async() => {
   try{
     const get_data = await axios.get("URL");
   }
   catch(error){
     console.log(error);
   }
 }

 // call the function
 fetchData();
Enter fullscreen mode Exit fullscreen mode

This has really helped me a lot and I have no complaints, but when talking about performance and being an external library, this question arises.

thanks for reading :D

Comments 2 total

  • Sebastian Wessel
    Sebastian WesselApr 5, 2023

    I used native fetch for the first time now, and I like it.
    The Rust-style with response.ok instead of throwing is easier to handle/read.
    Also, the timeout handling, JSON en/decoding is working out of the box.
    If you do not need to support node versions which do not provide native fetch - go for fetch

    • Javico11
      Javico11Apr 11, 2023

      Tks Sebastian for your kind opinion, if I have read a little about those advantages.

Add comment