aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/api/index.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-07-15 09:48:11 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:53 +0300
commit9057ca1824f0d5ba32478dd1ead9f97a5e44c387 (patch)
tree586aee95cb94df5af6e2d0e6d2e329e65297a970 /vnext/src/api/index.js
parent07f74dd46ecb18eac2047d4042919f1b092b682d (diff)
localStorage -> cookies
Diffstat (limited to 'vnext/src/api/index.js')
-rw-r--r--vnext/src/api/index.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js
index c9ae5688..efa57cf1 100644
--- a/vnext/src/api/index.js
+++ b/vnext/src/api/index.js
@@ -1,4 +1,5 @@
import axios from 'axios';
+import cookies from 'react-cookies';
const apiBaseUrl = 'https://api.juick.com';
@@ -6,11 +7,9 @@ const client = axios.create({
baseURL: apiBaseUrl
});
client.interceptors.request.use(config => {
- if (localStorage.visitor) {
- config.params = Object.assign(config.params || {}, {
- hash: JSON.parse(localStorage.visitor).hash
- });
- }
+ config.params = Object.assign(config.params || {}, {
+ hash: cookies.load('hash')
+ });
return config;
});
@@ -22,10 +21,11 @@ export function me(username = '', password = '') {
'Authorization': 'Basic ' + window.btoa(unescape(encodeURIComponent(username + ':' + password)))
} : {}
}).then(response => {
- localStorage.visitor = JSON.stringify(response.data);
- resolve(response.data);
+ let visitor = response.data;
+ cookies.save('hash', visitor.hash, { path: '/' });
+ resolve(visitor);
}).catch(reason => {
- localStorage.clear();
+ cookies.remove('hash', { path: '/'});
reject(reason);
});
});