Skip to content

Commit

Permalink
🔊 Add log to pinpoint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nwingt authored and williamchong committed Jan 24, 2025
1 parent babad20 commit 6c2ff41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/server/api/routes/bookstore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ router.get('/bookstore/products', async (req, res, next) => {
const { limit: pageSize, offset, tag } = req.query;

const tagId = tag || 'all';

console.log('/bookstore/products req.query', req.query);

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

View workflow job for this annotation

GitHub Actions / Deploy

Unexpected console statement

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

View workflow job for this annotation

GitHub Actions / CI

Unexpected console statement
const result = await fetchAirtableCMSProductsByTagId(tagId, {
pageSize,
offset: Array.isArray(offset) ? offset.join('/') : offset,
Expand All @@ -55,6 +55,8 @@ router.get('/bookstore/products', async (req, res, next) => {

res.json(result);
} catch (error) {
console.error('/bookstore/products error', error);

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

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

if (error.response?.status === 422) {
res.status(404).send('TAG_NOT_FOUND');
return;
Expand Down
15 changes: 9 additions & 6 deletions src/server/api/util/airtable.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ async function fetchAirtableCMSProductsByTagId(
tagId,
{ pageSize = 100, offset }
) {
const params = {
filterByFormula: 'NOT(Hidden)',
pageSize,
view: normalizeTagIdForViewName(tagId),
};
if (offset) {
params.offset = offset;
}
const results = await axios.get(
`https://api.airtable.com/v0/${AIRTABLE_CMS_BASE_ID}/${AIRTABLE_CMS_PRODUCTS_TABLE_ID}`,
{
headers: {
Authorization: `Bearer ${AIRTABLE_API_SECRET}`,
},
params: {
filterByFormula: 'NOT(Hidden)',
pageSize,
view: normalizeTagIdForViewName(tagId),
offset,
},
params,
}
);

Expand Down

0 comments on commit 6c2ff41

Please sign in to comment.