remove unnecessary data from article list api endpoint

This commit is contained in:
scoliono 2020-09-07 15:36:40 -07:00
parent 3799357a3e
commit bb69cf9321
2 changed files with 3 additions and 1 deletions

View File

@ -8,6 +8,7 @@ export async function get(req, res)
if (slug === 'all') {
articles = await Article.find()
.sort({ created_at: 'desc' })
.select('title slug image created_at views')
.populate({ path: 'category' })
.populate({ path: 'author', select: 'realname' });
} else {
@ -23,6 +24,7 @@ export async function get(req, res)
} else {
articles = await Article.find({ category: cat.id })
.sort({ created_at: 'desc' })
.select('title slug image created_at views')
.populate({ path: 'category' })
.populate({ path: 'author', select: 'realname' });
}

View File

@ -3,7 +3,7 @@
{
const res = await this.fetch(`/c/all.json`);
const { articles } = await res.json();
return { articles };
return { articles, randomArticle };
}
</script>