-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpRequest.js
More file actions
26 lines (23 loc) · 863 Bytes
/
httpRequest.js
File metadata and controls
26 lines (23 loc) · 863 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
let XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
// function httpGetAsync(theUrl, callback)
// {
// var xmlHttp = new XMLHttpRequest();
// xmlHttp.onreadystatechange = function() {
// if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
// callback(xmlHttp.responseText);
// }
// xmlHttp.open("GET", theUrl, true); // true for asynchronous
// xmlHttp.send(null);
// }
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
console.log(xmlHttp.status);
console.log('---------------------------------');
console.log(xmlHttp.getAllResponseHeaders());
console.log('---------------------------------');
console.log(xmlHttp.responseText);
}
httpGet('https://www.google.com/');