-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path34_request_API.html
More file actions
29 lines (28 loc) · 959 Bytes
/
34_request_API.html
File metadata and controls
29 lines (28 loc) · 959 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Request API with XML http request</title>
</head>
<body style="background-color: black; color: aliceblue;">
0 UNSENT Client has been created. open() not called yet.
1 OPENED open() has been called.
2 HEADERS_RECEIVED send() has been called, and headers and status are available.
3 LOADING Downloading; responseText holds partial data.
4 DONE The operation is complete.
</body>
<script>
const reqURL = 'https://api.github.com/users/Rishav07-05'
const xhr = new XMLHttpRequest();
xhr.open('GET' , reqURL)
xhr.onreadystatechange = function(){
console.log(xhr.readyState)
if (xhr.readyState === 4) {
const data = JSON.parse(this.responseText);
console.log(data.followers);
}
}
xhr.send()
</script>
</html>