Skip to content

Instantly share code, notes, and snippets.

@matt-mcalister
Created January 18, 2018 14:31
Show Gist options
  • Save matt-mcalister/ec85f9f1cdd9cb965ced46c5d4095c95 to your computer and use it in GitHub Desktop.
Save matt-mcalister/ec85f9f1cdd9cb965ced46c5d4095c95 to your computer and use it in GitHub Desktop.
fetchFromBackEnd(){
fetch("http://localhost:3000/api/v1/notes")
.then(response => response.json())
.then(notes => {
// render sidebar notes
for (const note of notes) {
let newNote = new Note({title: note.title, body: note.body, id: note.id});
newNote.createSidebarDiv()
}
// sidebar eventlistener (show note)
this.sideBar.addEventListener('click', this.handleShowFullNote.bind(this));
// new note button listener
this.newNote.addEventListener('click', this.handleNewNote.bind(this));
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment