From f66ff6fe82c575a5e71678234c9518a6a537927c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 17 Dec 2018 12:24:52 +0300 Subject: Anonymous comments --- vnext/src/api/index.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'vnext/src/api/index.js') diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js index 46efa159..2332ed48 100644 --- a/vnext/src/api/index.js +++ b/vnext/src/api/index.js @@ -1,7 +1,7 @@ import axios from 'axios'; import cookies from 'react-cookies'; -const apiBaseUrl = 'https://api.juick.com'; +const apiBaseUrl = 'https://juick.com'; const client = axios.create({ baseURL: apiBaseUrl @@ -15,8 +15,7 @@ client.interceptors.request.use(config => { export function me(username = '', password = '') { return new Promise((resolve, reject) => { - - client.get('/me', { + client.get('/api/me', { headers: username ? { 'Authorization': 'Basic ' + window.btoa(unescape(encodeURIComponent(username + ':' + password))) } : {} @@ -32,15 +31,15 @@ export function me(username = '', password = '') { } export function info(username) { - return client.get(`/info/${username}`); + return client.get(`/api/info/${username}`); } export function getChats() { - return client.get('/groups_pms'); + return client.get('/api/groups_pms'); } export function getChat(userName) { - return client.get('/pm', { + return client.get('/api/pm', { params: { 'uname': userName } @@ -51,7 +50,7 @@ export function pm(userName, body) { let form = new FormData(); form.set('uname', userName); form.set('body', body); - return client.post('/pm', form); + return client.post('/api/pm', form); } export function getMessages(path, params) { @@ -64,7 +63,7 @@ export function post(body, attach) { let form = new FormData(); form.append('attach', attach); form.append('body', body); - return client.post('/post', form); + return client.post('/api/post', form); } export function comment(mid, rid, body, attach) { @@ -73,17 +72,17 @@ export function comment(mid, rid, body, attach) { form.append('rid', rid); form.append('body', body); form.append('attach', attach); - return client.post('/comment', form); + return client.post('/api/comment', form); } export function updateAvatar(newAvatar) { let form = new FormData(); form.append('avatar', newAvatar); - return client.post('/me/upload', form); + return client.post('/api/me/upload', form); } function socialLink(network) { - return `${apiBaseUrl}/_${network}login?state=${window.location.protocol}//${window.location.host}${window.location.pathname}`; + return `${apiBaseUrl}/api/_${network}login?state=${window.location.protocol}//${window.location.host}${window.location.pathname}`; } export function facebookLink() { @@ -95,5 +94,13 @@ export function vkLink() { } export function markReadTracker(msg, visitor) { - return `${apiBaseUrl}/thread/mark_read/${msg.mid}-${msg.rid || 0}.gif?hash=${visitor.hash}`; + return `${apiBaseUrl}/api/thread/mark_read/${msg.mid}-${msg.rid || 0}.gif?hash=${visitor.hash}`; +} + +export function fetchUserUri(dataUri) { + return new Promise((resolve, reject) => { + let form = new FormData(); + form.append('uri', dataUri); + client.post('/u/', form).then(response => resolve(response)); + }); } -- cgit v1.2.3