Created
February 28, 2021 14:54
-
-
Save shridharkalagi/e3136dcc5880f56f0b1b0e78d519747d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PromisePool from '@supercharge/promise-pool' | |
import fetch from 'node-fetch' | |
usersList = ['user1', 'user2', ...'usern'] | |
const { results, errors } = await PromisePool.withConcurrency(10) | |
.for(usersList) | |
.process(async (user) => { | |
const url = 'https://api.github.com/users/' + user | |
fetch(url, { | |
method: 'GET', | |
headers: {}, | |
}).then((response) => resolve([response.status, user])) | |
return [response.status, user] | |
}) | |
results.forEach((element) => { | |
const statusCode = element[0] | |
const url = element[1] | |
if (statusCode != 200) { | |
console.log('Status code ' + statusCode + ' for url ' + url) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment