Next.js Discord

Discord Forum

Serverless function silently failing with Stripe

Unanswered
Orinoco Crocodile posted this in #help-forum
Open in Discord
Orinoco CrocodileOP
I am using the stripe nodejs library to create a customer in one of my api routes. The customer gets created however the function does not return anything at all. I do have the function in a try/catch block but no error is caught.

The first thing I did was to contact Stripe and after some trial an error, we realized that running the code block with just Nodejs does the trick. So the issue is actually the vercel environment. Any thoughts?

import { stripe } from '../utils';

const handler = async (req, res) => {
    const { first_name, last_name, email } = req.body.record;

    const args = {
        name: `${first_name} ${last_name}`,
        email
    }

    try {
        const customer = await stripe.customers.create(args);
        console.log(customer.id)
    } catch (err) {
        console.log(err);
    }
};

export default handler;

0 Replies