Skip to content

Commit

Permalink
return all wares for the given marketplace
Browse files Browse the repository at this point in the history
the default api setting is to return 25 wares per page. so, we were only
returning 25 wares total on the browse page. we now are returning "all"
wares by choosing to get 2000 wares per page in the api request. I
didn't see a way to set `page: "all"` or `per_page: "all"`.

if a marketplace has more than 2000 wares, we will need to increase the
number.
  • Loading branch information
alishaevn committed Nov 30, 2023
1 parent d55f360 commit a047ff4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/api/services.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import useSWR from 'swr'
import { API_PER_PAGE } from '../constants'

/** GET METHODS */
export const useAllWares = (accessToken) => {
const { data, error } = useSWR([`/wares.json`, accessToken])
const { data, error } = useSWR([`/wares.json?per_page=${API_PER_PAGE}`, accessToken])

return {
wares: data?.ware_refs,
Expand All @@ -12,7 +13,7 @@ export const useAllWares = (accessToken) => {
}

export const useFilteredWares = (query, accessToken) => {
const { data, error } = useSWR([`/wares.json?q=${query}`, accessToken])
const { data, error } = useSWR([`/wares.json?per_page=${API_PER_PAGE}&q=${query}`, accessToken])

return {
wares: data?.ware_refs.filter(item => item.slug !== 'make-a-request'),
Expand Down
2 changes: 2 additions & 0 deletions utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export const FEATURED_SERVICE_PATH = '/requests/new'
// the default is 1 week
export const EXPIRATION_DURATION = 604800000

export const API_PER_PAGE = 2000

export const WEBHOOK_EVENTS = {
'signer': {
'signature_voided': false,
Expand Down

0 comments on commit a047ff4

Please sign in to comment.