-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ky to fetch data from server #350
base: master
Are you sure you want to change the base?
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/eventyay/open-event-next/JBbK68o7ViLPkAaRfbFxwZizbkbG |
Please see....build is failing |
pages/index.tsx
Outdated
{ | ||
name: 'is-promoted', | ||
op: 'eq', | ||
val: true, | ||
}, | ||
]) | ||
const [group, groupErr] = await fetcher( | ||
'groups', | ||
`filter=${promotedGroupFilter}&include=user,follower&page[size]=3&public=true` | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refactor the other api calls in some similar way. It will make easier to debug the system.
utils/fetcher.ts
Outdated
searchParams: string | ||
): Promise<[data: ServerProp | null, err: any]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass a parameter for API call method too. Right now we can only make get
requests.
utils/fetcher.ts
Outdated
searchParams: string | ||
): Promise<[data: ServerProp | null, err: any]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass a parameter for API call method too. Right now we can only make get
requests.
pages/index.tsx
Outdated
const [event, eventErr] = await fetcher(eventUrl) | ||
const [event, eventErr] = await fetcher( | ||
'events', | ||
'filter=%5B%7B%22and%22%3A%5B%7B%22name%22%3A%22state%22%2C%22op%22%3A%22eq%22%2C%22val%22%3A%22published%22%7D%2C%7B%22name%22%3A%22privacy%22%2C%22op%22%3A%22eq%22%2C%22val%22%3A%22public%22%7D%2C%7B%22or%22%3A%5B%7B%22name%22%3A%22is-featured%22%2C%22op%22%3A%22eq%22%2C%22val%22%3Atrue%7D%2C%7B%22name%22%3A%22is-promoted%22%2C%22op%22%3A%22eq%22%2C%22val%22%3Atrue%7D%2C%7B%22and%22%3A%5B%7B%22name%22%3A%22logo-url%22%2C%22op%22%3A%22ne%22%2C%22val%22%3Anull%7D%2C%7B%22name%22%3A%22original-image-url%22%2C%22op%22%3A%22ne%22%2C%22val%22%3Anull%7D%2C%7B%22name%22%3A%22event-topic%22%2C%22op%22%3A%22ne%22%2C%22val%22%3Anull%7D%2C%7B%22name%22%3A%22event-sub-topic%22%2C%22op%22%3A%22ne%22%2C%22val%22%3Anull%7D%2C%7B%22name%22%3A%22event-type%22%2C%22op%22%3A%22ne%22%2C%22val%22%3Anull%7D%5D%7D%5D%7D%2C%7B%22name%22%3A%22is-sessions-speakers-enabled%22%2C%22op%22%3A%22eq%22%2C%22val%22%3Atrue%7D%2C%7B%22name%22%3A%22is-demoted%22%2C%22op%22%3A%22eq%22%2C%22val%22%3Afalse%7D%2C%7B%22name%22%3A%22speakers-call%22%2C%22op%22%3A%22has%22%2C%22val%22%3A%7B%22name%22%3A%22privacy%22%2C%22op%22%3A%22eq%22%2C%22val%22%3A%22public%22%7D%7D%2C%7B%22name%22%3A%22speakers-call%22%2C%22op%22%3A%22has%22%2C%22val%22%3A%7B%22name%22%3A%22starts-at%22%2C%22op%22%3A%22le%22%2C%22val%22%3A%222022-03-09T11%3A52%3A46.823Z%22%7D%7D%2C%7B%22name%22%3A%22speakers-call%22%2C%22op%22%3A%22has%22%2C%22val%22%3A%7B%22name%22%3A%22ends-at%22%2C%22op%22%3A%22ge%22%2C%22val%22%3A%222022-03-09T11%3A52%3A46.823Z%22%7D%7D%2C%7B%22name%22%3A%22speakers-call%22%2C%22op%22%3A%22has%22%2C%22val%22%3A%7B%22name%22%3A%22announcement%22%2C%22op%22%3A%22ne%22%2C%22val%22%3Anull%7D%7D%5D%7D%2C%7B%22or%22%3A%5B%7B%22name%22%3A%22ends-at%22%2C%22op%22%3A%22ge%22%2C%22val%22%3A%222022-03-09T11%3A52%3A46.822Z%22%7D%2C%7B%22name%22%3A%22starts-at%22%2C%22op%22%3A%22ge%22%2C%22val%22%3A%222022-03-09T11%3A52%3A46.822Z%22%7D%5D%7D%5D&include=event-topic%2Cevent-sub-topic%2Cevent-type%2Cspeakers-call&page%5Bsize%5D=6&public=true&sort=starts-at' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added it for testing. We should refactor it in the way I did below for groups with correct parameters.
pages/index.tsx
Outdated
{ | ||
name: 'is-promoted', | ||
op: 'eq', | ||
val: true, | ||
}, | ||
]) | ||
const [group, groupErr] = await fetcher( | ||
'groups', | ||
`filter=${promotedGroupFilter}&include=user,follower&page[size]=3&public=true` | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refactor the other api calls in some similar way. It will make easier to debug the system.
pages/index.tsx
Outdated
const [event, eventErr] = await fetcher(eventUrl) | ||
const [event, eventErr] = await fetcher( | ||
'events', | ||
'filter=%5B%7B%22and%22%3A%5B%7B%22name%22%3A%22state%22%2C%22op%22%3A%22eq%22%2C%22val%22%3A%22published%22%7D%2C%7B%22name%22%3A%22privacy%22%2C%22op%22%3A%22eq%22%2C%22val%22%3A%22public%22%7D%2C%7B%22or%22%3A%5B%7B%22name%22%3A%22is-featured%22%2C%22op%22%3A%22eq%22%2C%22val%22%3Atrue%7D%2C%7B%22name%22%3A%22is-promoted%22%2C%22op%22%3A%22eq%22%2C%22val%22%3Atrue%7D%2C%7B%22and%22%3A%5B%7B%22name%22%3A%22logo-url%22%2C%22op%22%3A%22ne%22%2C%22val%22%3Anull%7D%2C%7B%22name%22%3A%22original-image-url%22%2C%22op%22%3A%22ne%22%2C%22val%22%3Anull%7D%2C%7B%22name%22%3A%22event-topic%22%2C%22op%22%3A%22ne%22%2C%22val%22%3Anull%7D%2C%7B%22name%22%3A%22event-sub-topic%22%2C%22op%22%3A%22ne%22%2C%22val%22%3Anull%7D%2C%7B%22name%22%3A%22event-type%22%2C%22op%22%3A%22ne%22%2C%22val%22%3Anull%7D%5D%7D%5D%7D%2C%7B%22name%22%3A%22is-sessions-speakers-enabled%22%2C%22op%22%3A%22eq%22%2C%22val%22%3Atrue%7D%2C%7B%22name%22%3A%22is-demoted%22%2C%22op%22%3A%22eq%22%2C%22val%22%3Afalse%7D%2C%7B%22name%22%3A%22speakers-call%22%2C%22op%22%3A%22has%22%2C%22val%22%3A%7B%22name%22%3A%22privacy%22%2C%22op%22%3A%22eq%22%2C%22val%22%3A%22public%22%7D%7D%2C%7B%22name%22%3A%22speakers-call%22%2C%22op%22%3A%22has%22%2C%22val%22%3A%7B%22name%22%3A%22starts-at%22%2C%22op%22%3A%22le%22%2C%22val%22%3A%222022-03-09T11%3A52%3A46.823Z%22%7D%7D%2C%7B%22name%22%3A%22speakers-call%22%2C%22op%22%3A%22has%22%2C%22val%22%3A%7B%22name%22%3A%22ends-at%22%2C%22op%22%3A%22ge%22%2C%22val%22%3A%222022-03-09T11%3A52%3A46.823Z%22%7D%7D%2C%7B%22name%22%3A%22speakers-call%22%2C%22op%22%3A%22has%22%2C%22val%22%3A%7B%22name%22%3A%22announcement%22%2C%22op%22%3A%22ne%22%2C%22val%22%3Anull%7D%7D%5D%7D%2C%7B%22or%22%3A%5B%7B%22name%22%3A%22ends-at%22%2C%22op%22%3A%22ge%22%2C%22val%22%3A%222022-03-09T11%3A52%3A46.822Z%22%7D%2C%7B%22name%22%3A%22starts-at%22%2C%22op%22%3A%22ge%22%2C%22val%22%3A%222022-03-09T11%3A52%3A46.822Z%22%7D%5D%7D%5D&include=event-topic%2Cevent-sub-topic%2Cevent-type%2Cspeakers-call&page%5Bsize%5D=6&public=true&sort=starts-at' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added it for testing. We should refactor it in the way I did below for groups with correct parameters.
Fixes #300