Skip to content
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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

progmatic-99
Copy link
Contributor

Fixes #300

@vercel
Copy link

vercel bot commented Mar 4, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/eventyay/open-event-next/JBbK68o7ViLPkAaRfbFxwZizbkbG
✅ Preview: https://open-event-next-git-fork-progmatic-99-ky-eventyay.vercel.app

hongquan
hongquan previously approved these changes Mar 4, 2022
@pc-beast
Copy link
Member

pc-beast commented Mar 4, 2022

Please see....build is failing

pages/index.tsx Outdated
Comment on lines 77 to 86
{
name: 'is-promoted',
op: 'eq',
val: true,
},
])
const [group, groupErr] = await fetcher(
'groups',
`filter=${promotedGroupFilter}&include=user,follower&page[size]=3&public=true`
)
Copy link
Member

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
Comment on lines 5 to 6
searchParams: string
): Promise<[data: ServerProp | null, err: any]> {
Copy link
Member

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
Comment on lines 5 to 6
searchParams: string
): Promise<[data: ServerProp | null, err: any]> {
Copy link
Member

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'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

why??

Copy link
Member

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
Comment on lines 77 to 86
{
name: 'is-promoted',
op: 'eq',
val: true,
},
])
const [group, groupErr] = await fetcher(
'groups',
`filter=${promotedGroupFilter}&include=user,follower&page[size]=3&public=true`
)
Copy link
Member

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'
Copy link
Member

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.

@progmatic-99
Copy link
Contributor Author

Build working on my local, not here
ss_1648662396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup ky instance
3 participants