Separated GET and POST calls

This commit is contained in:
Jori Lallo 2016-07-23 12:09:50 -07:00
parent 885a1a0953
commit 71f68a8af4
6 changed files with 11 additions and 7 deletions

View File

@ -4,7 +4,7 @@ export default function methodOverride(options) {
return async function methodOverrideMiddleware(ctx, next) {
if (ctx.method === 'POST') {
ctx.body = ctx.request.body;
} else {
} else if (ctx.method === 'GET') {
ctx.method= 'POST';
ctx.body = queryString.parse(ctx.querystring);
}

View File

@ -13,7 +13,7 @@ const store = new class AtlasStore {
this.atlas = null;
try {
const res = await client.post('/atlases.info', { id: id });
const res = await client.get('/atlases.info', { id: id });
const { data } = res;
this.atlas = data;
successCallback(data);
@ -24,4 +24,4 @@ const store = new class AtlasStore {
}
}();
export default store;
export default store;

View File

@ -39,7 +39,7 @@ class DocumentEditStore {
this.isFetching = true;
try {
const data = await client.post('/documents.info', {
const data = await client.get('/documents.info', {
id: this.documentId,
});
if (this.newChildDocument) {

View File

@ -48,7 +48,7 @@ class DocumentSceneStore {
this.updatingContent = softLoad;
try {
const res = await client.post('/documents.info', { id: id });
const res = await client.get('/documents.info', { id: id });
const { data } = res;
runInAction('fetchDocument', () => {
this.document = data;

View File

@ -18,7 +18,7 @@ class SearchStore {
if (query) {
try {
const res = await client.post('/documents.search', { query });
const res = await client.get('/documents.search', { query });
const { data, pagination } = res;
runInAction('search document', () => {
this.documents = data;

View File

@ -77,10 +77,14 @@ class ApiClient {
});
}
post = (path, data) => {
get = (path, data) => {
return this.fetch(path, 'GET', data);
}
post = (path, data) => {
return this.fetch(path, 'POST', data);
}
// Helpers
constructQueryString = (data) => {