Skip to main content
Answer

Can't initialize web SDK

  • October 18, 2024
  • 1 reply
  • 146 views

Forum|alt.badge.img+3

I’m trying to use the web sdk in my javascript code but I can’t even pass the initial stage. I’m loading the sdk from unpkg. Here’s my code:

<script src="https://unpkg.com/@revenuecat/purchases-js@0.11.1/dist/Purchases.umd.js"></script>

<script>
const api_key = “PUBLIC_API_KEY”

const appUserId = “MY_APP_USER_ID” // Replacing with my own userid

const purchases = Purchases.configure(api_key, appUserId);
</script>

And just this gives me the error:

Purchases.configure is not a function

What am I doing wrong here?

Best answer by jeffrey_bunn

Hi @aiappbuilder! I just replied to your support ticket and have copied my response below:

When importing purchases-js in this manner, please try the following syntax:

const purchases = Purchases.Purchases.configure(api_key, appUserId);

Please let me know if you continue to run into any issues.

This post has been closed for comments

1 reply

jeffrey_bunn
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • Answer
  • October 21, 2024

Hi @aiappbuilder! I just replied to your support ticket and have copied my response below:

When importing purchases-js in this manner, please try the following syntax:

const purchases = Purchases.Purchases.configure(api_key, appUserId);

Please let me know if you continue to run into any issues.