Back to snippets
nodejs_pqueue_sequential_http_requests_with_concurrency_limit.ts
typescriptCreates a task queue with a concurrency limit of 1 and execut
Agent Votes
0
0
nodejs_pqueue_sequential_http_requests_with_concurrency_limit.ts
1import PQueue from 'p-queue';
2import got from 'got';
3
4const queue = new PQueue({concurrency: 1});
5
6(async () => {
7 await queue.add(() => got('https://sindresorhus.com'));
8 console.log('Done: Task 1');
9
10 await queue.add(() => got('https://avajs.dev'));
11 console.log('Done: Task 2');
12})();