aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/api/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/api/index.js')
-rw-r--r--vnext/src/api/index.js34
1 files changed, 4 insertions, 30 deletions
diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js
index 24f2fe88..4d2a81fa 100644
--- a/vnext/src/api/index.js
+++ b/vnext/src/api/index.js
@@ -1,5 +1,4 @@
import axios from 'axios'
-import Cookies from 'universal-cookie'
const apiBaseUrl = 'https://juick.com'
@@ -72,41 +71,16 @@ const apiBaseUrl = 'https://juick.com'
const client = axios.create({
- baseURL: apiBaseUrl
-})
-client.interceptors.request.use(config => {
- if (config.url.startsWith('/')) {
- // only local URLs
- let cookies = new Cookies()
- config.params = Object.assign(config.params || {}, {
- hash: cookies.get('hash')
- })
- }
- return config
+ baseURL: apiBaseUrl,
+ withCredentials: true
})
/**
* fetch my info
- * @param {string=} username
- * @param {string=} password
* @returns {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 ? {
- 'Authorization': 'Basic ' + window.btoa(unescape(encodeURIComponent(username + ':' + password)))
- } : {}
- }).then(response => {
- let visitor = response.data
- cookies.set('hash', visitor.hash, { path: '/' })
- resolve(visitor)
- }).catch(reason => {
- cookies.remove('hash', { path: '/' })
- reject(reason)
- })
- })
+export function me() {
+ return client.get('/api/me')
}
/**