From bb69cf93212887dd5f008de1ccb02b3788d894b0 Mon Sep 17 00:00:00 2001 From: scoliono <2191476+scoliono@users.noreply.github.com> Date: Mon, 7 Sep 2020 15:36:40 -0700 Subject: [PATCH] remove unnecessary data from article list api endpoint --- src/routes/c/[slug].json.js | 2 ++ src/routes/index.svelte | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/routes/c/[slug].json.js b/src/routes/c/[slug].json.js index 594222f..6763a68 100644 --- a/src/routes/c/[slug].json.js +++ b/src/routes/c/[slug].json.js @@ -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' }); } diff --git a/src/routes/index.svelte b/src/routes/index.svelte index f9381d4..dcbf579 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -3,7 +3,7 @@ { const res = await this.fetch(`/c/all.json`); const { articles } = await res.json(); - return { articles }; + return { articles, randomArticle }; }