diff options
author | Vitaly Takmazov | 2020-10-12 01:23:41 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:55 +0300 |
commit | ccceb785b70eece5a8a9c7a34b44ce59eb159f21 (patch) | |
tree | 0b32c4ebe0a91bc967e8b91eba919962de5e3823 /vnext/src/api | |
parent | 884c5ca43f80dae6bcd5bd294d3e566dec87eb24 (diff) |
react-cookies -> react-cookie + universal-cookie
Diffstat (limited to 'vnext/src/api')
-rw-r--r-- | vnext/src/api/index.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js index d5fb6ba7..2392bfd0 100644 --- a/vnext/src/api/index.js +++ b/vnext/src/api/index.js @@ -1,5 +1,5 @@ import axios from 'axios'; -import cookies from 'react-cookies'; +import Cookies from 'universal-cookie'; const apiBaseUrl = 'https://juick.com'; @@ -71,8 +71,9 @@ const client = axios.create({ baseURL: apiBaseUrl }); client.interceptors.request.use(config => { + let cookies = new Cookies(); config.params = Object.assign(config.params || {}, { - hash: cookies.load('hash') + hash: cookies.get('hash') }); return config; }); @@ -84,6 +85,7 @@ client.interceptors.request.use(config => { * @return {Promise<SecureUser, Error>} me object */ export function me(username = '', password = '') { + let cookies = new Cookies(); return new Promise((resolve, reject) => { client.get('/api/me', { headers: username ? { @@ -91,7 +93,7 @@ export function me(username = '', password = '') { } : {} }).then(response => { let visitor = response.data; - cookies.save('hash', visitor.hash, { path: '/' }); + cookies.set('hash', visitor.hash, { path: '/' }); resolve(visitor); }).catch(reason => { cookies.remove('hash', { path: '/'}); |