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

Create authenticated reminder endpoint #169

Merged
merged 17 commits into from
Aug 18, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Switch between geocoding in prod and dev
  • Loading branch information
maxwofford committed Aug 18, 2022
commit 3edeb446ec25f3f134c5a09d4ea1d98f72364bdf
9 changes: 6 additions & 3 deletions lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,20 @@ export const getGroupingData = async () => ({
emailStats: (await getEmailStats()) || {}
})

const subscriberTable = process.env.VERCEL_ENV === 'production' ?
'subscribers' :
'subscribers_development'

export const getSubscriber = async id => {
const select = { filterByFormula: `{id} = '${id}'`, maxRecords: 1 }
let subscribers = await getJSON(
`https://api2.hackclub.com/v0.1/hackathons.hackclub.com/subscribers_development?select=${JSON.stringify(select)}&authKey=${process.env.AIRTABLE_API_KEY}`
`https://api2.hackclub.com/v0.1/hackathons.hackclub.com/${subscriberTable}?select=${JSON.stringify(select)}&authKey=${process.env.AIRTABLE_API_KEY}`
)
console.log(`https://api2.hackclub.com/v0.1/hackathons.hackclub.com/subscribers_development?select=${JSON.stringify(select)}&authKey=${process.env.AIRTABLE_API_KEY}`)
return subscribers[0]
}

export const updateSubscriber = async (id, fields) => {
return await fetch(`https://api2.hackclub.com/v0.1/hackathons.hackclub.com/subscribers_development/?authKey=${process.env.AIRTABLE_API_KEY}`, {
return await fetch(`https://api2.hackclub.com/v0.1/hackathons.hackclub.com/${subscriberTable}?authKey=${process.env.AIRTABLE_API_KEY}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json', },
body: JSON.stringify({ id, fields }),
Expand Down