From b5f5f7569e0457b7f8251e12179a822353adb470 Mon Sep 17 00:00:00 2001 From: brian Date: Mon, 22 Mar 2021 14:13:56 -0400 Subject: [PATCH] switched to actual api, not stub --- api.js | 7 ++++++- handlers/App.js | 3 +-- handlers/Note.js | 3 +-- handlers/index.js | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/api.js b/api.js index ddc9132..7dafe10 100644 --- a/api.js +++ b/api.js @@ -1,9 +1,14 @@ +// for development, to use api-stub, just import it here and export it at the end; +// it's a one-liner that switches from stub to actual api + const api = {}; +let prefix = "/api"; + api.post = function(url, body){ return m.request({ method: 'POST', - url, + prefix+url, body }); }; diff --git a/handlers/App.js b/handlers/App.js index eec0e3a..25002be 100644 --- a/handlers/App.js +++ b/handlers/App.js @@ -1,6 +1,5 @@ import nanoid from '../nanoid.min.js'; -//import api from '../api.js'; -import api from '../api-stub.js'; +import api from '../api.js'; const load_notes = function(state, dispatch){ api.post('/load-notes', {bin_id: state.bin.id}) diff --git a/handlers/Note.js b/handlers/Note.js index e69de5d..8056046 100644 --- a/handlers/Note.js +++ b/handlers/Note.js @@ -1,5 +1,4 @@ -//import api from '../api.js'; -import api from '../api-stub.js'; +import api from '../api.js'; const edit_handler = function(note_state, dispatch){ dispatch('update-note-editing', {id: note_state.note.id, is_editing: true}); diff --git a/handlers/index.js b/handlers/index.js index 75a2160..4230b43 100644 --- a/handlers/index.js +++ b/handlers/index.js @@ -1,4 +1,4 @@ -import api from '../api-stub.js'; +import api from '../api.js'; const load_bin_handler = function(state, dispatch, bin_id){ /*