lopps get axios in javascript

index.tsx
// Example of looping to make multiple axios requests in JavaScript

const axios = require('axios');
const urls = ['https://api.example.com/data1', 'https://api.example.com/data2', 'https://api.example.com/data3'];

// Function to make axios requests
const makeRequests = async () => {
    for (const url of urls) {
        try {
            const response = await axios.get(url);
            console.log(response.data);
        } catch (error) {
            console.error(error);
        }
    }
};

makeRequests();
517 chars
19 lines

related categories

gistlibby LogSnag