Skip to content

Commit

Permalink
Fix a fetcher to work with swr > 2
Browse files Browse the repository at this point in the history
  • Loading branch information
majakomel committed Oct 25, 2023
1 parent 5eff361 commit 6cf8552
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions pages/as/[probe_asn].js
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,12 @@ const NetworkDashboard = ({ probe_asn, networkName, countriesData }) => {
const { data: calendarData, error: calendarDataError } = useSWR(
[
'/api/v1/aggregation',
{
{ params: {
probe_asn,
since: dayjs.utc().subtract(12, 'year').format('YYYY-MM-DD'),
until: dayjs.utc().add(1, 'day').format('YYYY-MM-DD'),
axis_x: 'measurement_start_day',
},
{
},
resultKey: 'result',
preprocessFn: prepareDataForCalendar,
},
Expand Down
2 changes: 1 addition & 1 deletion services/fetchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const MATFetcher = (query) => {

export const simpleFetcher = (url, params) => (client.get(url, { params }).then(res => res.data.results))

export const fetcherWithPreprocessing = (url, params, {resultKey = 'results', preprocessFn}) => {
export const fetcherWithPreprocessing = ([url, {params, resultKey = 'results', preprocessFn}]) => {
return client.get(url, { params }).then(res => {
if (preprocessFn) return preprocessFn(res.data[resultKey])
return res.data[resultKey]
Expand Down

1 comment on commit 6cf8552

@vercel
Copy link

@vercel vercel bot commented on 6cf8552 Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

explorer – ./

explorer-git-master-ooni1.vercel.app
explorer-ooni1.vercel.app
explorer-one.vercel.app

Please sign in to comment.