From bf30f108faffa72782acbb8fa645b6586960218a Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Thu, 23 May 2019 12:23:54 -0600 Subject: [PATCH] Move saveToken() to account/utilities.js --- src/js/account/helpers.js | 6 ------ src/js/account/login.js | 3 ++- src/js/account/sync.js | 3 ++- src/js/account/utilities.js | 5 +++++ 4 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 src/js/account/utilities.js diff --git a/src/js/account/helpers.js b/src/js/account/helpers.js index 40ae175..5ac353b 100644 --- a/src/js/account/helpers.js +++ b/src/js/account/helpers.js @@ -1,5 +1,3 @@ -import { setCookie } from "../StackOverflow/cookie"; - export function request (data = {}, success = () => {}, error = () => {}/* , fail = () => {} */) { return fetch('./api/', { method: 'POST', // or 'PUT' @@ -17,7 +15,3 @@ export function request (data = {}, success = () => {}, error = () => {}/* , fai return success(response.data); }); } - -export function saveToken(token) { - setCookie('token', token, 30); -} \ No newline at end of file diff --git a/src/js/account/login.js b/src/js/account/login.js index ae3e35c..fc984f1 100644 --- a/src/js/account/login.js +++ b/src/js/account/login.js @@ -1,4 +1,5 @@ -import { request, saveToken } from "./helpers"; +import { request } from "./helpers"; +import { saveToken } from "./utilities"; import { addMessage } from "../utilities"; import { setupLogoutButton } from "./setupListeners"; import { renderAccountSettings } from "./render"; diff --git a/src/js/account/sync.js b/src/js/account/sync.js index abe4aad..46faef7 100644 --- a/src/js/account/sync.js +++ b/src/js/account/sync.js @@ -1,6 +1,7 @@ import { addMessage } from "../utilities"; import { saveDictionary, clearDictionary } from "../dictionaryManagement"; -import { request, saveToken } from "./helpers"; +import { request } from "./helpers"; +import { saveToken } from "./utilities"; import { renderAll } from "../render"; import { sortWords } from "../wordManagement"; diff --git a/src/js/account/utilities.js b/src/js/account/utilities.js new file mode 100644 index 0000000..746de3a --- /dev/null +++ b/src/js/account/utilities.js @@ -0,0 +1,5 @@ +import { setCookie } from "../StackOverflow/cookie"; + +export function saveToken(token) { + setCookie('token', token, 30); +} \ No newline at end of file