From 91c14f0d2ae37cc061c3b492d56974564ed77351 Mon Sep 17 00:00:00 2001 From: Denis Ah-Kang Date: Wed, 18 Feb 2026 15:12:36 +0400 Subject: [PATCH] the embedded property may be missing if the underlying collection is empty --- lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 1505cdf..20d5e9d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -74,12 +74,12 @@ Ctx.prototype.fetch = async function (options, cb) { req.end(function (err, res) { if (err) return cb(err); if (!res.ok) return cb(res.text); - cb(null, arrayify(res.body[embedKey][key])); + cb(null, arrayify(res.body?.[embedKey]?.[key] ?? [])); }); } , function (err, allRes) { if (err) return cb(err); - var allData = arrayify(body[embedKey][key]); + var allData = arrayify(body?.[embedKey]?.[key] ?? []); allRes.forEach(function (res) { allData = allData.concat(res); }); cb(null, allData); }