Closed jsjoeio closed 1 year ago
For the font stuff, maybe this will work: https://stackoverflow.com/a/25963902/3015595
More:
There are two tasks to be completed here. I will write them both out and how to achieve them:
Using the Beehiiv API, get the total count of subscribers
BEEHIIV_API_KEY
(add to Vercel too). This can be found heresrc/pages/getWaitlistTotal.json.ts
to use Beehiiv's API. Example:const url = 'https://api.beehiiv.com/v2/publications/pub_6fcf5bfc-5793-49e6-b6b2-abcf322a6fd7/subscriptions?status=active&tier=all&limit=1';
const options = {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${BEEHIIV_API_KEY}`
}
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
The response will look something like this:
{
"data": [
{}
],
"page": 1,
"limit": 1,
"total_results": 2,
"total_pages": 2
}
All we need is total_results
.
It will be similar to the above but for src/pages/updateWaitlistTotal.json.ts
and we'll do this in src/components/CTA.tsx
. We'll need to update the frontend to not submit the form but instead:
updateWaitlistTotal
/thank-you
page upon successSpoke to Beehiiv Team and they said they're down to extend my API access even after my free trial expires so this approach will work :D
Link: https://developers.beehiiv.com/docs/v2/1f82a0eaf9b68-create
Worried that if I integrate this while I'm on the free trial, it won't work after that's up 🤔 Not sure though so may need to reach out to support and ask.