I am trying to only call a promise once the previous one has succeeded. I am looping through all the zipcodes in the us and hitting up an api to get information back from it. I need the promises to execute after one another and not in parallel.
here is my current code.
const fetchDealersByZipProx = function() {
const prox = [30, 50, 100];
states.map(({ abbr }) => {
zipcodes.lookupByState(abbr).map(({ zip }) => {
prox.map(async p => {
const result = await fetch(
`${apiBaseURL}/${zip}/${p}`
).then(res => res.json);
console.log(result);
});
});
});
};