Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Help required with listAllSubscriptions() #13

Open
devArno88 opened this issue May 9, 2023 · 0 comments
Open

Help required with listAllSubscriptions() #13

devArno88 opened this issue May 9, 2023 · 0 comments

Comments

@devArno88
Copy link

devArno88 commented May 9, 2023

I am trying to implement a NextJS API route to identify a single subscription by user email. So far the route looks like this:

const subscriptions = await listAllSubscriptions({ apiKey: process.env.LEMON_API_KEY });
const exists = subscriptions.data.some((x) => x.attributes.user_email === session.user.email);
const subscription = exists ? subscriptions.data.filter((x) => x.attributes.user_email === session.user.email)[0].attributes : null;
res.status(200).json(subscription);

This works well in development, but in production Im receiving a 504 error with Vercel logs showing:

11:14:17 AM: Reconnecting to MongoDB for api/subscription
TypeError: fetchImpl is not a function
at wrappedFetch (/var/task/___vc/__launcher.js:133:16)
at u (file:///var/task/node_modules/lemonsqueezy.ts/dist/modules/subscription.mjs:1:437)
at R (file:///var/task/node_modules/lemonsqueezy.ts/dist/modules/subscription.mjs:1:1178)
at GET (/var/task/.next/server/pages/api/subscription.js:893:123)
at handler (/var/task/.next/server/pages/api/subscription.js:917:16)
at processTicksAndRejections (internal/process/task_queues.js:95:5)

Ive also tried this with

const client  = new LemonSqueezyClient(process.env.LEMON_API_KEY);
const subscriptions = await client.listAllSubscriptions()

but Im receiving the same error. Do you have any idea where I might be going wrong with this?

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant