-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathget_users.js
33 lines (26 loc) · 921 Bytes
/
get_users.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
//This file is autogenerated. See modules.json and autogenerator.py for details
/*
get_users.js
MediaWiki API Demos
Demo of `Users` module: Get information about several users: [[1.2.3.4]], [[Catrope]], [[Vandal01]], and [[Bob]]
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
list: "users",
ususers: "Catrope|Bob",
usprop: "blockinfo|groups|editcount|registration|emailable|gender",
format: "json"
};
url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
fetch(url)
.then(function(response){return response.json();})
.then(function(response) {
var users = response.query.users;
for (var u in users) {
console.log(users[u].name + " has " + users[u].editcount + " edits.");
}
})
.catch(function(error){console.log(error);});