Hello - Ok have been banging my head against the w...
# ask-a-descoper
l
Hello - Ok have been banging my head against the wall on this. I am using the Web JS SDK and trying to get it to work in WebFlow. When I try to access the SDK I am always getting
Uncaught TypeError: Descope is not a function
. The JS line is ->
const sdk = Descope({ projectId: "ID", persistTokens: true });
. Anyone else have this issue. I can see that
Descope
is instantiated as I can view it in the JS console. This is basically the code for every example so I am a little baffled. I get the same thing when I do a simple CodePen. Thanks!
s
Hey David Have you checked this https://github.com/orgs/descope/discussions/50 for webflow ?
l
Yea I have exactly. It fails on this code:
Copy code
<script> 
  const sdk = Descope({ projectId: "<project id>", persistTokens: true });
  
  .....
</script>
From this section -> https://docs.descope.com/knowledgebase/descopeflows/descopewebflow/descopewebflow/#handing-redirect-if-not-authenticated
s
@dazzling-oyster-96577 @salmon-night-88354 can you help here ?
l
Yes - I have the flow working, can login (kinda - not sure where the JWT is). Its just this sdk issue.
s
Not talking about the flow, specifically step 3 should enable the import of Descope sdk
Under custom code, head code
d
Agreed, this error only really occurs when there is invalid custom code, either syntax or missing an import, or you have another script conflicting that's overwriting some global variable or something like that. Please check your imports @lemon-refrigerator-38207
l
Ok so I followed the code exactly and same issue. I dug around the sdk code and figured out that this works.
Copy code
<script> 
  const sdk = Descope.default({ projectId: "<project id>", persistTokens: true });
  
  .....
</script>
And yea I checked my imports.
s
Ok, let us check this internally
l
@square-vr-55083 just FYI - I have everything working now with the use of
Descope.default
so I am unblocked but this is not consistent with your docs so ...
s
correct, we found an issue on our
latest
SDK , that makes it not working without the
.default
we are fixing it now also changing SDK version to latest released (
1.3.2
) will solve that
1
l
Thank you!
s
one note, we are going to fix it soon, after fix the
Descope.default
will not work looping in @great-diamond-35515 to update before that so your app won't break
g
Hey, we found the root cause, it is started to fail in
1.3.0
the fix will be avaialble in the next few hours, in the meantime I suggest to use
1.2.9
in general we descourage to use
@latest
tag (on any production dependency) and use a constant version, we will update the docs accordingly apologies for the inconvenience
👍🏼 1
l
Thanks for the help. 100% agree for production to pin the version. I was just trying to get the demo code going. Surprised automated testing did not catch this considering how much of your demo code is out there using it.\
I have pinned my code to
1.2.9
and removed
.default
and it is working fine now.
g
great 👏 FYI, we have now released a fix on version
1.3.3
s
Hey David, As Asaf said, this is now fixed, you can now use latest or set it with 1.3.3. Per our internal discussion, it's likely best to hard code this until you've thoroughly tested the future releases then update it. Once you use latest or 1.3.3, you can remove the default from the
sdk = Descope.default...
leaving it just
sdk = Descope...
🙌 1
👍 1