-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.js
More file actions
35 lines (29 loc) · 747 Bytes
/
Copy pathgithub.js
File metadata and controls
35 lines (29 loc) · 747 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
const https = require("https");
//github account
let username = 'foxneo';
// User agent to get the data
let FIREFOX_USER_AGENT = "Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/13.0 Firefox/40.1"
// Url and http method
let options = {
host: 'api.github.com',
path: '/users/' + username,
method: 'GET',
headers: { 'user-agent': FIREFOX_USER_AGENT}
};
// Make the request
let request = https.request(options, (response) =>{
let body = '';
response.on('data', (out) => {
body += out;
});
response.on('end', (out) =>{
let json = JSON.parse(body);
console.log(json);
});
});
// server doesnt response
request.on('error', (e) =>{
console.log(e);
});
// close the request
request.end();