Skip to content

Instantly share code, notes, and snippets.

@matt-mcalister
Created January 18, 2018 14:53
Show Gist options
  • Save matt-mcalister/384d8e3e2e26990071a68ceba099d61b to your computer and use it in GitHub Desktop.
Save matt-mcalister/384d8e3e2e26990071a68ceba099d61b to your computer and use it in GitHub Desktop.
async fetchFromBackEnd(){
this.notes = await fetch("http://localhost:3000/api/v1/notes").then(response => response.json())
// render sidebar notes
for (const note of this.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