Last active
January 23, 2023 11:57
-
-
Save israelalagbe/cd20a496784784f437fc68c873043fc6 to your computer and use it in GitHub Desktop.
Test rate limit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var axios = require("axios"); | |
const promises = []; | |
for(i=0;i< 5;i++) { | |
promises.push(callApi()) | |
} | |
let success = 0, error = 0; | |
Promise.all(promises).finally(() => { | |
console.log({ | |
success, error | |
}) | |
}); | |
async function callApi() { | |
try { | |
var data = JSON.stringify({ | |
userName: "", | |
password: "", | |
}); | |
var config = { | |
method: "post", | |
url: " url goes here ", | |
headers: { | |
"Content-Type": "application/json", | |
}, | |
data: data, | |
}; | |
await axios(config); | |
success++ | |
// console.log(JSON.stringify(response.data)); | |
} catch (e) { | |
error++ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment