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 f96a661
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/api/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,9 @@ export default class ApiController {

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

ctx.body = school.toJSON();
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 f96a661

Please sign in to comment.