I am expanding my pet project (twitterwatcher.com/c/) with alerts, for that, I need to get a bit more details from the binance API, long story short I am receiving an error: 509, Bandwidth Limit Exceeded
I guess that I am sending the requests to the binance in a way to rapid manner - and I have to introduce a form of delay into my axios requests. And now here comes the problem - as my code is doing it automatically - how can I add the delays?
below the JS code:
let urls = ['A', 'B', 'C'] //this id dynamic
let output = null;
const responses = await axios.all(urls.map(x => axios.get(x)));
if(Array.isArray(responses)){
output = [];
responses.forEach(wip => {wip.data.forEach((element) => {
output.push({
//push the JSON in
});
});
})
}else{
output = [];
outputWiP.data.forEach((element) => {
output.push({
//push the JSON in
});
});
})
}
And a question:
- How can I introduce a 0.5s delay without major changes in the logic? I've seen solutions with .then() approach, I do not want to have a unique implementation in this piece of code (I am using async/await wherever I can).