Buttondown
export default async (req, res) => {
const API_KEY = process.env.BUTTONDOWN_API_KEY;
const response = await fetch('https://api.buttondown.email/v1/subscribers', {
headers: {
Authorization: `Token ${API_KEY}`,
'Content-Type': 'application/json'
},
method: 'GET'
});
const { count } = await response.json();
return res.status(200).json({ count });
};
Usage
First, create a Buttondown account.
From the settings page, retrieve your API key at the bottom.
To securely access the API, we need to include the secret with each request.
Remember: never commit secrets to git. Thus, we should use an environment variable.