using server.method() instead of direct call to $.ajax - preparation for electron without network requests

This commit is contained in:
azivner
2017-11-28 20:52:38 -05:00
parent 14001f67d8
commit 54c0ff15b3
17 changed files with 150 additions and 217 deletions

View File

@@ -93,15 +93,7 @@ const noteEditor = (function() {
}
async function saveNoteToServer(note) {
await $.ajax({
url: baseApiUrl + 'notes/' + note.detail.note_id,
type: 'PUT',
data: JSON.stringify(note),
contentType: "application/json",
error: () => {
showError("Error saving the note!");
}
});
await server.put('notes/' + note.detail.note_id, note);
isNoteChanged = false;
@@ -130,7 +122,7 @@ const noteEditor = (function() {
}
async function loadNoteToEditor(noteId) {
currentNote = await $.get(baseApiUrl + 'notes/' + noteId);
currentNote = await server.get('notes/' + noteId);
if (isNewNoteCreated) {
isNewNoteCreated = false;
@@ -167,7 +159,7 @@ const noteEditor = (function() {
}
async function loadNote(noteId) {
return await $.get(baseApiUrl + 'notes/' + noteId);
return await server.get('notes/' + noteId);
}
$(document).ready(() => {