-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi2.js
More file actions
41 lines (30 loc) · 901 Bytes
/
api2.js
File metadata and controls
41 lines (30 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const startTime = performance.now();
let userArray = ['jay-ponda', 'sagar', 'vijay', 'nirav-improwised']
let url = 'https://api.github.com/users/22222';
let found = 0;
let notFound = 0;
let userLength = userArray.length;
async function getUserInfo(user, index) {
await fetch(`https://api.github.com/users/${user}`, {
method: "GET",
headers: {
Authorization: '<your token here>'
}
})
.then((response) => {
if (!response.ok) {
notFound++
}
else {
found++;
}
})
if (userLength == (found + notFound)) {
console.log('found : ', found, ' notFound : ', notFound);
const endTime = performance.now();
console.log("time :", endTime - startTime);
}
}
userArray.forEach((user, index) => {
getUserInfo(user, index);
})