From 35f273b3ea37467642654604df8f105f38477140 Mon Sep 17 00:00:00 2001 From: NK Date: Wed, 1 Mar 2023 22:08:13 +0000 Subject: [PATCH] fix --- pages/api/skyblock.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pages/api/skyblock.js b/pages/api/skyblock.js index e8547f5..7420035 100644 --- a/pages/api/skyblock.js +++ b/pages/api/skyblock.js @@ -5,19 +5,17 @@ async function decodeData(buffer) { const parsedNbt = await parseNbt(Buffer.from(buffer, "base64")); return nbt.simplify(parsedNbt); } - +let dat; export default async function handler(req, res) { if (req.method == "GET") { try { - const {ByteData} = JSON.parse(req.body); - if (ByteData == undefined) - res.status(400).json({error: "ByteData is undefined"}); + dat = JSON.parse(req.body).ByteData; } catch (e) { - const {ByteData} = req.body; - if (ByteData == undefined) - res.status(400).json({error: "ByteData is undefined"}); + dat = req.body.ByteData; } - const data = await getItemNetworth((await decodeData(ByteData)).i[0], { + if (dat == undefined) + res.status(400).json({error: "ByteData is undefined"}); + const data = await getItemNetworth((await decodeData(dat)).i[0], { cache: true, }); res.status(200).json(data);