From df8bc75633deb1f10ea2cd1fc6f848344a8ead83 Mon Sep 17 00:00:00 2001 From: "gwanhyeong.lee" Date: Wed, 4 Nov 2020 21:13:07 +0900 Subject: [PATCH] Refactor ssr caching example --- examples/ssr-caching/server.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/ssr-caching/server.js b/examples/ssr-caching/server.js index 68e72ea504cbf..8d0a0927ab8be 100644 --- a/examples/ssr-caching/server.js +++ b/examples/ssr-caching/server.js @@ -14,11 +14,7 @@ const ssrCache = cacheableResponse({ const rawResEnd = res.end const data = await new Promise((resolve) => { res.end = (payload) => { - if (res.statusCode === 200) { - resolve(payload) - } else { - resolve() - } + resolve(res.statusCode === 200 && payload) } app.render(req, res, req.path, { ...req.query, @@ -36,9 +32,7 @@ app.prepare().then(() => { server.get('/', (req, res) => ssrCache({ req, res })) - server.get('/blog/:id', (req, res) => { - return ssrCache({ req, res }) - }) + server.get('/blog/:id', (req, res) => ssrCache({ req, res })) server.get('*', (req, res) => handle(req, res))