Documentation on stripe in edge function does not match implementation resulting in error.

I have reduced my edge function to just importing stripe and then creating the stripe client.

This throws an error in the edge function that says serve has already been declared.

import { serve } from "https://deno.land/std@0.131.0/http/server.ts";
import Stripe from "https://esm.sh/stripe?target=deno&no-check";
// import { getAccountLink } from '../shared/index.ts';

serve(async (req) => {
  const stripe = Stripe(Deno.env.get("STRIPE_API_KEY") ?? "", {
    // This is needed to use the Fetch API rather than relying on the Node http
    // package.
    httpClient: Stripe.createFetchHttpClient(),
    apiVersion: "2020-08-27",
  });
  // console.log(stripe)
  return new Response(
    JSON.stringify({ accountLink: 'https://google.com' }),
    { headers: { "Content-Type": "application/json" }, status: 200, statusText: 'OK' },
  )
})
Was this page helpful?