Fetching data using Axios
Axios is simply a lightweight JavaScript, promise-based HTTP client used to consume API services. It is mainly used in the browser and Node.js. To use Axios in our project, open the project terminal and type the following:
npm install axios
Now, let’s see how to use Axios in the following code snippet:
import React, { useEffect, useState } from 'react';import axios from 'axios'; const App = () => { const [data, setData] = useState([]); const getSpeakers = ()=>{ axios.get( "https://jsonplaceholder.typicode.com/users") .then(response => { setData(response.data) ...