add pin / unpin to api

This commit is contained in:
igoradamenko
2018-02-05 00:27:47 +02:00
parent 633a1b9125
commit d287a18969
+12 -3
View File
@@ -2,11 +2,13 @@ import { siteId, url } from './settings';
import fetcher from './fetcher'
/* common */
export const find = ({ url }) => fetcher.get(`/find?url=${url}&sort=-score&format=tree`);
export const getComment = ({ id }) => fetcher.get(`/id/${id}?url=${url}`);
export const getUser = () => fetcher.get('/user');
export const vote = ({ id, url, value }) => fetcher.put(`/vote/${id}?url=${url}&vote=${value}`);
export const send = ({ text, pid }) => fetcher.post('/comment', {
text,
@@ -17,12 +19,19 @@ export const send = ({ text, pid }) => fetcher.post('/comment', {
...(pid ? { pid } : {}),
});
export const vote = ({ id, url, value }) => fetcher.put(`/vote/${id}?url=${url}&vote=${value}`);
export const getUser = () => fetcher.get('/user');
/* admin */
export const pin = ({ id, url }) => fetcher.put(`/admin/pin/${id}?url=${url}&pin=1`);
export const unpin = ({ id, url }) => fetcher.get(`/admin/pin/${id}?url=${url}&pin=0`);
export default {
find,
getComment,
send,
pin,
unpin,
vote,
send,
getUser,
};