Coded Geekery

BlogWritingAboutContact
BlogWritingAboutContact

Revue

Subscribe to a newsletter.

export default async (req, res) => { const { email } = req.body; if (!email) { return res.status(400).json({ error: 'Email is required' }); } const result = await fetch('https://www.getrevue.co/api/v2/subscribers', { method: 'POST', headers: { Authorization: `Token ${process.env.REVUE_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ email }) }); const data = await result.json(); if (!result.ok) { return res.status(500).json({ error: data.error.email[0] }); } return res.status(201).json({ error: '' }); };

Usage#

  • Create Revue Account

  • First, create a Revue account.

  • Find API Key

  • From the Integrations page, retrieve your API key at the bottom.

  • Add Environment Variables

  • 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.

    Not Playing

    Spotify

    Coded Geekery

    TwitterGitHubInstagramgumroadbuymeacoffee

    Stuff

    HomeAbout MeContact Me

    © 2022 Roger Stringer. All rights reserved.