'Avoid 429 error after an axios.all request to a rapidapi service
I'm trying with this async function to get a list of people and then looping through them and using one id to fire an axios.all and get datas from all of them. The problem is that I'm getting a 429 too many requests error. that's the function:
const getData = async () => {
try {
const response = await axios.get('https://instagram-scraper-2022.p.rapidapi.com/ig/following/', {
params: { id_user: 'xxxxx' },
headers: {
'X-RapidAPI-Host': 'xxxxx',
'X-RapidAPI-Key': 'xxxxx'
}
})
const slicedUsers = response.data.users.slice(0, 5)
const getAllProfilesInfo = axios.all(slicedUsers.map(user => {
axios.get('https://instagram-bulk-profile-scrapper.p.rapidapi.com/clients/api/ig/ig_profile', {
params: { response_type: 'short', ig: user.username, corsEnabled: 'true' },
headers: {
'X-RapidAPI-Host': 'xxxx',
'X-RapidAPI-Key': 'xxxxxx'
}
})
}))
return getAllProfilesInfo
} catch (error) {
console.log(error)
}
}
I've tried to slice the array to stay within the 10 call x minutes limit, but I'm still getting the error. Which clever workarounds do we have on this situations? Also I'm getting undefined sometimes, without triggering the 429 issue, so not sure if I'm handling the repsonse well. Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
