Skip to content

Commit

Permalink
fix: return only createdAt when creating an article
Browse files Browse the repository at this point in the history
  • Loading branch information
Fayoke Adeyina authored and Fayoke Adeyina committed Aug 13, 2018
1 parent 851fd1d commit e109dd1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/controllers/ArticleController.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class ArticleController {
* @returns {object} the article that was created/updated.
*/
static articleResponse(article, statusCode, res) {
const updatedAt = statusCode === 201 ? undefined : new Date(article.updatedAt).toLocaleString('en-GB', { hour12: true });
return res.status(statusCode).send({
status: 'success',
message: statusCode === 201 ? 'The article has been created successfully' : `The article with slug: ${article.slug} has been updated successfully`,
Expand All @@ -30,7 +31,7 @@ export default class ArticleController {
body: article.body,
imageUrl: article.imageUrl,
createdAt: new Date(article.createdAt).toLocaleString('en-GB', { hour12: true }),
updatedAt: new Date(article.updatedAt).toLocaleString('en-GB', { hour12: true }),
updatedAt,
},
});
}
Expand Down

0 comments on commit e109dd1

Please sign in to comment.