Axios
one minute of reading
Axios is a popular JavaScript library that allows HTTP requests to be made from within a Node.js application. It was created with the idea of making the web easier to work with, and its main goal is to make communication between the application and the API simple and transparent.
Axios is a simple HTTP client with which we create requests in the browser and NodeJS. Its characteristic element is the use of the mechanism of so-called promises, that is, the executed query returns to us its status in the form of either reject or resolve.
In practice, queries to the API use "then" and "catch" syntaxes.
import axios from "axios";
axios.get('/users')
.then(res => {
console.log(res.data);
});
Interesting facts about how Axios works
Besides the ability to send Get and Post requests, Axios also provides other interesting mechanisms that make it easier to make requests to the API. Below I decided to present a list from the most important ones to the less important ones.
Axios config
Working in a project, we have the ability to create many customized Axios configs which we then import into the code. This allows us to create queries that use a different base_url or authorization method.
Axios interceptor
Axios interceptor gives us the ability to catch certain messages or events that occur during API implementation and act accordingly. For example, for any error with authorization, when our authorization token has expired we have the ability to recreate the token and resend the request without the user being aware of the event.
Axios and AbortController
As of version 0.22.0, Axios provides the ability to use AbortController, that is, to cancel a query that has been created. This provides a number of possibilities in the form of cancelling a long-running query while moving to another subpage of the application, or when the application logic requires it.
Related articles
Influence of Google Fonts on UX and UI Design
3 Aug 2023
In the fusion of UX and UI design, nothing is trivial. Each element, including typography, plays a pivotal role in engaging user interaction. This article focuses on understanding the crucial influence of Google Fonts on UX & UI design. We delve into its impact on aesthetics, functionality, and overall user experience.

Human-Centered Design: Pivotal Player in the Arena of Modern Technology Development
17 Jul 2023
Human-Centered Design, a novel paradigm in modern technology development, is ensuring a revolution in software designs by prioritizing the user experience. As a core approach to problem-solving, it carefully blends technology with human needs to deliver highly-effective and usable solutions.
Unleashing the Power: A Comprehensive Guide to Mastering Affiliate Marketing
17 Jul 2023
This guide will embark you on a journey through the realm of Affiliate Marketing, illuminating its potency and progressive ways to harness it. Step into the universe where partnerships flourish, revenues stream, and brands expand, using dynamic marketing strategies.
Mastering the Art: Effective Strategies for Lead Nurturing in Tech Industries
17 Jul 2023
Lead nurturing in the tech industry is akin to conducting a symphony, where every note must be played in perfect harmony. It requires patience, precision, and a keen sense of timing. This article gears towards deciphering strategies that can help tech businesses skilfully navigate this intricate realm, fostering stronger customer connections and maximizing lead conversion.
Unleashing the Potential of CKEditor for Seamless Content Creation
5 Jul 2023
In this article, we will explore how to unleash the full potential of CKEditor for seamless content creation. CKEditor is a powerful and versatile text editor that offers a wide range of features and customization options. By understanding its capabilities and implementing best practices, we can optimize content creation processes and enhance the overall user experience. Let's dive in and discover the possibilities that CKEditor brings to the table!
Unveiling the Wonders of Augmented Reality
5 Jul 2023
Augmented Reality is a groundbreaking technology that blends the virtual world with the real world, creating an immersive and interactive experience. From gaming and entertainment to education and healthcare, Augmented Reality has the potential to revolutionize various industries. In this article, we will explore the wonders of Augmented Reality and the endless possibilities it offers.
The Revolutionary Impact of Apache Hadoop on Big Data
5 Jul 2023
The emergence of Apache Hadoop has brought about a revolutionary impact on the world of big data. With its ability to process and analyze massive volumes of data in a distributed computing environment, Hadoop has enabled organizations to uncover valuable insights and make data-driven decisions.
Show all articles