Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 0e2a11a

Browse files
committed
Solve "Error status' problemn
1 parent 82cdbad commit 0e2a11a

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎Week1/assets/js.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
var xhr = new XMLHttpRequest();
55
xhr.open( 'GET' , 'https://api.github.com/orgs/HackYourFuture/repos?per_page=100%27' );
66
xhr.onload = function() {
7+
78
if(this.status == 200){
89
var repos = JSON.parse( this.responseText);
910
var output = '';
@@ -12,7 +13,15 @@
1213
}
1314
document.getElementById('reposs').innerHTML = output;
1415

16+
}else {
17+
document.getElementById('users').classList.add('NetwrkError');
18+
document.getElementById('users').innerHTML = "Netwrk error:" + this.status +' - '+ this.statusText;
1519
}
20+
21+
}
22+
xhr.onerror = function(){
23+
document.getElementById('users').classList.add('NetwrkError');
24+
document.getElementById('users').innerHTML = "Netwrk error:" + this.status +' - '+ this.statusText;
1625
}
1726

1827
xhr.send();
@@ -58,6 +67,10 @@ function loadUsers() {
5867
document.getElementById('users').innerHTML = "Netwrk error:" + this.status +' - '+ this.statusText;
5968
}
6069
}
70+
xhr.onerror = function(){
71+
document.getElementById('users').classList.add('NetwrkError');
72+
document.getElementById('users').innerHTML = "Netwrk error:" + this.status +' - '+ this.statusText;
73+
}
6174

6275
xhr.send();
6376

@@ -98,6 +111,10 @@ function loadUsers2(){
98111
document.getElementById('users2').innerHTML = "Netwrk error:" + this.status +' - '+ this.statusText;
99112
}
100113
}
114+
xhr.onerror = function(){
115+
document.getElementById('users2').classList.add('NetwrkError');
116+
document.getElementById('users2').innerHTML = "Netwrk error:" + this.status +' - '+ this.statusText;
117+
}
101118

102119
xhr.send();
103120
}

0 commit comments

Comments
 (0)