diff --git a/src/server/api/routes/bookstore/index.js b/src/server/api/routes/bookstore/index.js index 639bb417e..7d8191f24 100644 --- a/src/server/api/routes/bookstore/index.js +++ b/src/server/api/routes/bookstore/index.js @@ -43,7 +43,7 @@ router.get('/bookstore/products', async (req, res, next) => { const result = await fetchAirtableCMSProductsByTagId(tagId, { pageSize, - offset, + offset: decodeURIComponent(offset), }); if (!IS_TESTNET) { @@ -55,6 +55,7 @@ router.get('/bookstore/products', async (req, res, next) => { res.json(result); } catch (error) { + console.error(error); if (error.response?.status === 422) { res.status(404).send('TAG_NOT_FOUND'); return; diff --git a/src/util/api/index.js b/src/util/api/index.js index da7a472b9..498a48ee2 100644 --- a/src/util/api/index.js +++ b/src/util/api/index.js @@ -620,14 +620,14 @@ export const fetchBookstoreCMSTags = ({ limit = 100 } = {}) => export const fetchBookstoreCMSProductsByTagId = ( tagId, - { offset, t = BOOKSTORE_CMS_CACHE_RESET_TIMESTAMP, limit = 100 } = {} + { offset, t = BOOKSTORE_CMS_CACHE_RESET_TIMESTAMP, limit = 30 } = {} ) => { const qsPayload = { tag: tagId, limit, t, }; - if (offset) qsPayload.offset = offset; + if (offset) qsPayload.offset = encodeURIComponent(offset); return `${EXTERNAL_HOST}/api/bookstore/products?${querystring.stringify( qsPayload )}`;