From 8988233da897e8447a1dbdb700836fb8576e5e6b Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Wed, 11 Dec 2019 18:54:05 +0530 Subject: :tada: Initial Commit --- src/services/http.service.js | 0 src/services/storage.service.js | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/services/http.service.js create mode 100644 src/services/storage.service.js (limited to 'src/services') diff --git a/src/services/http.service.js b/src/services/http.service.js new file mode 100644 index 0000000..e69de29 diff --git a/src/services/storage.service.js b/src/services/storage.service.js new file mode 100644 index 0000000..c41d552 --- /dev/null +++ b/src/services/storage.service.js @@ -0,0 +1,16 @@ +class Storage{ + static get = (key)=>{ + if(!key)throw("Storage.get expects a 'key' - 'key' can't be null"); + if(!localStorage.getItem(key)) return null; + return localStorage.getItem(key); + } + + static set = (key, value)=>{ + if(!key||!value){ + throw("Storag.set expects a 'key' and a 'value' - 'value' & 'key' can't be null"); + } + localStorage.setItem(key, JSON.stringify(value)); + } +} + +export default Storage; \ No newline at end of file -- cgit v1.2.3