Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d215b67

Browse files
committed
Check for valid HTTP 2xx responses
1 parent 2e3be8f commit d215b67

File tree

3 files changed

+2
-4
lines changed

3 files changed

+2
-4
lines changed

homework-classes/App.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,4 @@ class App {
7575
}
7676

7777
const HYF_REPOS_URL = 'https://api.github.com/orgs/HackYourFuture/repos?per_page=100';
78-
7978
window.onload = () => new App(HYF_REPOS_URL);

homework-classes/Util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Util {
2222
xhr.open('GET', url);
2323
xhr.responseType = 'json';
2424
xhr.onload = () => {
25-
if (xhr.status < 400) {
25+
if (xhr.status >= 200 && xhr.status <= 299) {
2626
resolve(xhr.response);
2727
} else {
2828
reject(new Error(`Network error: ${xhr.status} - ${xhr.statusText}`));

homework/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
xhr.open('GET', url);
77
xhr.responseType = 'json';
88
xhr.onload = () => {
9-
if (xhr.status < 400) {
9+
if (xhr.status >= 200 && xhr.status <= 299) {
1010
cb(null, xhr.response);
1111
} else {
1212
cb(new Error(`Network error: ${xhr.status} - ${xhr.statusText}`));
@@ -42,6 +42,5 @@
4242
}
4343

4444
const HYF_REPOS_URL = 'https://api.github.com/orgs/HackYourFuture/repos?per_page=100';
45-
4645
window.onload = () => main(HYF_REPOS_URL);
4746
}

0 commit comments

Comments
 (0)