-
Notifications
You must be signed in to change notification settings - Fork 0
/
weboftrust.js
35 lines (30 loc) · 1.02 KB
/
weboftrust.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
const https = require('https');
var apiKey = "";
function checkDomains(hosts){
var promise = new Promise(function(resolve, reject) {
if (apiKey == "" ) reject(Error("Please set the api key using the function setApiKey(KEY)"));
var str = ''
var path = '/0.4/public_link_json2?hosts=';
hosts.forEach(function(host){
path += host + '/'
})
path += '&key='+apiKey;
var options = {
host: 'api.mywot.com',
path: path
};
https.request(options, function(res){
res.on('data', function(chunk){
str += chunk;
});
res.on('end', function () {
result = JSON.parse(str);
if (result == '' || result == {}) reject(Error("Error using Web Of Trust: "+error));
resolve(result);
});
}).end();
});
return promise;
}
exports.setApiKey = function(key){ apiKey = key; }
exports.checkDomains = checkDomains;