diff options
Diffstat (limited to 'src/services')
-rw-r--r-- | src/services/http.service.js | 0 | ||||
-rw-r--r-- | src/services/storage.service.js | 16 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/services/http.service.js b/src/services/http.service.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/services/http.service.js 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 |