Skip to main content
Solved

Can't initialize web SDK

  • October 18, 2024
  • 1 reply
  • 95 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.

View original
Did this post help you find an answer to your question?
This post has been closed for comments

1 reply

jeffrey_bunn
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 299 replies
  • 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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings