-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApirequest.html
34 lines (31 loc) · 1.08 KB
/
Apirequest.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body style="background-color: #212121; color : #e4e1eff5">
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.
<button id="button">Card</button>
</body>
<script>
const button = document.querySelector('#button')
const requestUrl = 'https://api.github.com/users/gaurisonawane07'
const xhr = new XMLHttpRequest();
xhr.open('GET',requestUrl)
xhr.onreadystatechange = function(){
console.log(xhr.readyState);
if(xhr.readyState === 4){
const data = JSON.parse(this.responseText)
console.log(this.responseText);
console.log(data.avatar_url);
}
}
const event = xhr.send()
</script>
</html>