Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pLimit giving me a list of undefined promises #67

Closed
ralyodio opened this issue Feb 19, 2023 · 1 comment
Closed

pLimit giving me a list of undefined promises #67

ralyodio opened this issue Feb 19, 2023 · 1 comment

Comments

@ralyodio
Copy link

        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.

@SleeplessByte
Copy link

You're not returning the result of the limit function.

// Your code 
.map((..) => { ... })

// Explicit return
.map((..) => { return ... })

// Implicit return
.map((..) => ...)

@sindresorhus sindresorhus closed this as not planned Won't fix, can't repro, duplicate, stale Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants