Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
week2 in progress
  • Loading branch information
chichiglacierz committed Aug 31, 2019
commit 8a09787120be1dae85340abc078a6d72acbf81a7
31 changes: 18 additions & 13 deletions homework/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
'use strict';

{
function fetchJSON(url, cb) {
const xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.responseType = 'json';
xhr.onload = () => {
if (xhr.status < 400) {
cb(null, xhr.response);
} else {
cb(new Error(`Network error: ${xhr.status} - ${xhr.statusText}`));
}
};
xhr.onerror = () => cb(new Error('Network request failed'));
xhr.send();
function fetchJSON(url) {
const p = new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.responseType = 'json';
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
if (xhr.status < 400) {
resolve(xhr.response);
} else {
reject(new Error(xhr.statusText));
}
}
console.log();
};
xhr.send();
});
}
const REPOS_URL = 'https://api.github.com/orgs/foocoding/repos?per_page=100';

function createAndAppend(name, parent, options = {}) {
// name: the elem/thing that we want to create.
Expand Down