-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.cjs
37 lines (25 loc) · 908 Bytes
/
index.cjs
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
'use strict';
const axios = require('axios');
const _ = require('lodash');
const baseUrl = 'https://api.statistron.xyz';
module.exports = (opts, callback) => {
return new Promise((resolve, reject) => {
opts = opts || '';
let url = '/v1/wikistats';
if (!_.isUndefined(opts.flags.number) && opts.flags.number != '') {
url += '?q=random&limit=' + opts.flags.number;
console.log(url)
}
else {url += '?q=random&limit=5'}
axios.get(baseUrl + url)
.then(response => {
if (response.data && _.isArray(response.data)) {
let result = response.data;
// console.log (result)
return resolve(result);
}
return resolve(response.data);
})
.catch(err => reject(err));
});
};