Skip to content

Instantly share code, notes, and snippets.

@israelalagbe
Last active January 23, 2023 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save israelalagbe/cd20a496784784f437fc68c873043fc6 to your computer and use it in GitHub Desktop.
Save israelalagbe/cd20a496784784f437fc68c873043fc6 to your computer and use it in GitHub Desktop.
Test rate limit
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