Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
ApiController#createSchool(): Use fetched school object to make respo…
Browse files Browse the repository at this point in the history
…nse with

Recently inserted object ('school' variable) doesn't contain unset school properties filled with default values (e. g. 'post_count')
  • Loading branch information
artkravchenko committed Nov 21, 2016
1 parent b8a5b6c commit 1628f1e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/api/controller.js
Expand Up @@ -743,7 +743,10 @@ export default class ApiController {

await school.save(null, { method: 'insert' });

ctx.body = school.toJSON();
// 'school' variable doesn't contain default school properties (e.g. 'post_count')
const newSchool = await School.where({ name }).fetch({ require: true });

ctx.body = newSchool.toJSON();
} catch (e) {
ctx.status = 500;
ctx.body = { error: e.message };
Expand Down

0 comments on commit 1628f1e

Please sign in to comment.