remove unnecessary data from article list api endpoint
This commit is contained in:
parent
3799357a3e
commit
bb69cf9321
@ -8,6 +8,7 @@ export async function get(req, res)
|
|||||||
if (slug === 'all') {
|
if (slug === 'all') {
|
||||||
articles = await Article.find()
|
articles = await Article.find()
|
||||||
.sort({ created_at: 'desc' })
|
.sort({ created_at: 'desc' })
|
||||||
|
.select('title slug image created_at views')
|
||||||
.populate({ path: 'category' })
|
.populate({ path: 'category' })
|
||||||
.populate({ path: 'author', select: 'realname' });
|
.populate({ path: 'author', select: 'realname' });
|
||||||
} else {
|
} else {
|
||||||
@ -23,6 +24,7 @@ export async function get(req, res)
|
|||||||
} else {
|
} else {
|
||||||
articles = await Article.find({ category: cat.id })
|
articles = await Article.find({ category: cat.id })
|
||||||
.sort({ created_at: 'desc' })
|
.sort({ created_at: 'desc' })
|
||||||
|
.select('title slug image created_at views')
|
||||||
.populate({ path: 'category' })
|
.populate({ path: 'category' })
|
||||||
.populate({ path: 'author', select: 'realname' });
|
.populate({ path: 'author', select: 'realname' });
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
{
|
{
|
||||||
const res = await this.fetch(`/c/all.json`);
|
const res = await this.fetch(`/c/all.json`);
|
||||||
const { articles } = await res.json();
|
const { articles } = await res.json();
|
||||||
return { articles };
|
return { articles, randomArticle };
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user