aboutsummaryrefslogtreecommitdiff
path: root/pages/api
diff options
context:
space:
mode:
authorA i j a Z <[email protected]>2023-10-22 21:48:33 +0530
committerGitHub <[email protected]>2023-10-22 23:18:33 +0700
commit100edf23426501e2f2f420ba8a70dd022e4027af (patch)
treecb5326b2a17c270af550ad1bcd6882f916d5be02 /pages/api
parentfixed redis (#94) (diff)
downloadmoopa-100edf23426501e2f2f420ba8a70dd022e4027af.tar.xz
moopa-100edf23426501e2f2f420ba8a70dd022e4027af.zip
fixed redis error for manga (#95)
* fixed schedules * fixed redis * Update [...id].js * Update index.js
Diffstat (limited to 'pages/api')
-rw-r--r--pages/api/v2/info/index.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/pages/api/v2/info/index.js b/pages/api/v2/info/index.js
index 95770bd..39795d3 100644
--- a/pages/api/v2/info/index.js
+++ b/pages/api/v2/info/index.js
@@ -39,10 +39,12 @@ export default async function handler(req, res) {
try {
let cached;
// const data = await fetchInfo(id);
- cached = await redis.get(`manga:${id}`);
+ if (redis) {
+ cached = await redis.get(`manga:${id}`);
- if (cached) {
- return res.status(200).json(JSON.parse(cached));
+ if (cached) {
+ return res.status(200).json(JSON.parse(cached));
+ }
}
const manga = await fetchInfo(id);
@@ -51,7 +53,7 @@ export default async function handler(req, res) {
return res.status(404).json({ error: "Manga not found" });
}
- await redis.set(`manga:${id}`, JSON.stringify(manga), "ex", 60 * 60 * 24);
+ if (redis) await redis.set(`manga:${id}`, JSON.stringify(manga), "ex", 60 * 60 * 24);
res.status(200).json(manga);
} catch (error) {