-
Notifications
You must be signed in to change notification settings - Fork 0
/
anotherApproach.js
45 lines (41 loc) · 991 Bytes
/
anotherApproach.js
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
41
42
43
44
45
let login=true;
let Data= [];
let Detail=[];
async function getData(){
const myData = await fetch(`https://api.github.com/users`);
const result = await myData.json();
for(s in result){
Data.push(result[s].login);
}
}
async function getDetail(){
for(s of Data){
const myData = await fetch(`https://api.github.com/users/${s}`,{
headers: {
authorization: "token xxxxxxxxxxxxxxxxxxxxxxxx"
}
});
const result = await myData.json();
Detail.push(result);
}
login=false;
}
async function main() {
let time = Date.now();
let r1 = await getData();
let r2 = await getDetail();
let timeEnd = Date.now();
console.log(Detail)
console.log("Time: "+(timeEnd-time)/1000);
}
main();
let myInterval= setInterval(
()=>{
if (login==true){
console.log("loading...");
}
else {
clearInterval(myInterval);
}
},500
)