node js sleep between axios
const bluebird = require('bluebird') async function makeRequests (lines) { await bluebird.map( lines, async (line) => { const encodedLink = encodeURI(line.link) const response = await axios.get(encodedLink) // ...your response handling code here... }, { concurrency: 3 } ) } makeRequests(jsonParsed)
Here is what the above code is Doing:
1. We’re using the bluebird library to map over the array of links.
2. We’re using the axios library to make the requests.
3. We’re using the encodeURI function to encode the links.
4. We’re using the concurrency option to limit the number of concurrent requests to 3.