Created
February 28, 2021 14:32
-
-
Save shridharkalagi/4f7b85390acb5f3f525ca928b28c09db 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 fetch from 'node-fetch' | |
usersList = ['user1', 'user2', ...'usern'] | |
let userRequests = [] | |
Object.values(usersList).forEach((user) => { | |
userRequests.push(getEachUser(user)) | |
}) | |
function getEachUser(user) { | |
return new Promise((resolve, reject) => { | |
const url = 'https://api.github.com/users/' + user | |
fetch(url, { | |
method: 'GET', | |
headers: {}, | |
}).then((response) => resolve([response.status, user])) | |
}) | |
} | |
await Promise.all(userRequests).then((responseData) => { | |
responseData.forEach((element) => { | |
const statusCode = element[0] | |
const user = element[1] | |
assert.equal(statusCode, 200, 'API call failed for user ' + user) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment