DAY 22 OF
100 DAY REACT.JS
API CALLING
USING
AXIOS
IN REACT
ADVANCE REACT PT - 1
ASHWIN MALI
DAY 22 OF
100 DAY REACT.JS
WHAT IS
AXIOS?
Axios is a popular JavaScript library used for making HTTP
requests from web browsers or Node.js environments. It
simplifies the process of sending asynchronous HTTP
requests to a server and handling the responses. Axios is
often employed in web development for fetching data from
APIs and interacting with backend services.
Installation :
Write in project terminal
Import Axios methods
into project
ASHWIN MALI
DAY 22 OF
100 DAY REACT.JS
1.
axios.get(url[, config])
axios.get(url[, config]) is a method used in the Axios library for
making HTTP GET requests.
url: This is the URL to which the request will be sent.
config (optional): This is an optional configuration object
that you can provide to customize the request. The config
object may include various properties, such as headers,
query parameters, authentication information, and more.
ASHWIN MALI
DAY 22 OF
100 DAY REACT.JS
2.
axios.post(url[, data[, config]])
The axios.post(url[, data[, config]]) method is part of the Axios
library in JavaScript, used for making HTTP POST requests.
url: This is the URL to which the POST request will be sent.
data (optional): This parameter represents the data that you want
to send with the POST request. It is typically used for sending
information to the server, such as form data or JSON payloads.
config (optional): This is an optional configuration object that you
can provide to customize the request. The config object may include
various properties, such as headers, authentication information, and
more.
ASHWIN MALI
DAY 22 OF
100 DAY REACT.JS
2.
axios.interceptors:
Axios interceptors allow you to run your code or modify the
request or response before the request is sent or after the
response is received.
You can use axios.interceptors.request.use() to register a
function that will be called before each request is sent.
This function receives the request configuration and can modify it or
perform any custom logic before the request is actually made.
ASHWIN MALI
DAY 22 OF
100 DAY REACT.JS
FOLLOW
ASHWIN MALI
Approach to BCA | HTML5 | CSS | JavaScript |
🚀
React.js | Java | C++
DON’T FORGET TO SAVE