Skip to content

Commit

Permalink
🚑 Fix bookstore pagination offset
Browse files Browse the repository at this point in the history
  • Loading branch information
nwingt committed Jan 23, 2025
1 parent a89e388 commit 7d0733f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/server/api/routes/bookstore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -55,6 +55,7 @@ router.get('/bookstore/products', async (req, res, next) => {

res.json(result);
} catch (error) {
console.error(error);

Check warning on line 58 in src/server/api/routes/bookstore/index.js

View workflow job for this annotation

GitHub Actions / CI

Unexpected console statement

Check warning on line 58 in src/server/api/routes/bookstore/index.js

View workflow job for this annotation

GitHub Actions / Deploy

Unexpected console statement
if (error.response?.status === 422) {
res.status(404).send('TAG_NOT_FOUND');
return;
Expand Down
4 changes: 2 additions & 2 deletions src/util/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
)}`;
Expand Down

0 comments on commit 7d0733f

Please sign in to comment.