I am trying to axios requests inside a for loop but the loop is being completed even before the axios. Following is my code:
let findEmail = async() => {
for (var i = 0; i < csvData.length; i++){
axios.post('https://email-finder.herokuapp.com/find', {
"first_name": "Irinaa",
"last_name": "xyz",
"domain": "xyxz.com"
}).then((response) => {
if(response.status === 500){
console.log('no email found');
}
else{
console.log(response.data);
}
}, (error) => {
console.log('no email found ', i);
});
console.log('axios request done');
}
}
I want the loop to wait until the request is complete and then go to increment the i variable. Any help would be much appreciated. Thank you