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) { return async function methodOverrideMiddleware(ctx, next) {
if (ctx.method === 'POST') { if (ctx.method === 'POST') {
ctx.body = ctx.request.body; ctx.body = ctx.request.body;
} else { } else if (ctx.method === 'GET') {
ctx.method= 'POST'; ctx.method= 'POST';
ctx.body = queryString.parse(ctx.querystring); ctx.body = queryString.parse(ctx.querystring);
} }

View File

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

View File

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

View File

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

View File

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

View File

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