Skip to content
Open

Done #128

Changes from all commits
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
39 changes: 35 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
const token = getToken()

function getIssues() {
}
const fork = `shoppersaysso/javascript-fetch-lab`
fetch(`https://api.github.com/repos/${fork}/issues`, {
method: 'get',
headers: {
Authorization: `token ${token}`
}
}).then(resp => resp.json()).then(data => showIssues(data))
}

function showIssues(json) {
}
var div = document.getElementById("issues")
for (var i = 0, l = json.length; i < l; i++) {
$("#issues").append(`<li>${json[i].title}</li>`)
}

}

function createIssue() {
var title = document.getElementById("title").value
var body = document.getElementById("body").value
var issue = {title: title, body: body}
fetch(`https://api.github.com/repos/shoppersaysso/javascript-fetch-lab/issues`, {
method: 'post',
headers: {
'Authorization': `token ${token}`
},
body: JSON.stringify(issue)
}).then(resp => getIssues());

}

function showResults(json) {
$('#results').append(`<h3>Fork:</h3><a href="${json.html_url}"> ${json.html_url}</a> - ${json.name}`)
}

function forkRepo() {
const repo = 'learn-co-curriculum/javascript-fetch-lab'
//use fetch to fork it!
fetch(`https://api.github.com/repos/learn-co-curriculum/javascript-fetch-lab/forks`, {
method: 'post',
headers: {
Authorization: `token ${token}`
}
}).then(res => res.json()).then(json => showResults(json));

}

function getToken() {
Expand Down