const maxParallelRequests = 1;
const limit = pLimit(maxParallelRequests);
// Use the map method to create an array of promises for each call to GetData
const promises = items.map(item => {
limit(() => this.getData(item))
});
When I log promises
I get an array of 60 undefined
items.
What am I doing wrong here?
item
is defined inside the map function.
I had to add return in the map:
// Use the map method to create an array of promises for each call to GetData
const promises = items.map(item => {
return limit(() => this.getData(item))
});