Skip to content
Open

Done #134

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
31 changes: 28 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
function getIssues() {
fetch(`${'https://api.github.com/'}repos/${`${'emanovic7'}/javascript-fetch-lab`}/issues`).
then(resp => {
resp.json().then( data => {
for (let i = 0; i < data.length; i++){
displayIssue(new Issue(data[i]));
}
} )
})
}

function showIssues(json) {
}

function createIssue() {
const issueTitle = document.getElementById('title').value
const issueBody = document.getElementById('body').value
const postData = { title: issueTitle, body: issueBody }
fetch(`${'https://api.github.com/'}repos/${`${'emanovic7'}/javascript-fetch-lab`}/issues`, {
method: 'post',
headers: {
'Authorization': `token ${getToken()}`
},
body: JSON.stringify(postData)
}).then(resp => getIssues())
}

function showResults(json) {
}

function forkRepo() {
const repo = 'learn-co-curriculum/javascript-fetch-lab'
//use fetch to fork it!

fetch(`${'https://api.github.com/'}repos/${repo}/forks`, {
method: 'post',
headers: {
'Authorization': `token ${getToken()}`
}
}).then(resp => {
let repo = new Repo(resp);
showForkedRepo(repo);
})
}

function getToken() {
//change to your token to run in browser, but set
//back to '' before committing so all tests pass
return ''
}