Good afternoon! I am trying to follow the guide he...
# support-questions
m
Good afternoon! I am trying to follow the guide here to retrieve a userID: https://supertokens.com/docs/emailpassword/common-customizations/get-user-info however typehinting the req and adding a ! into the statement is causing a syntax error. How else can I grab the user ID?
r
hey @M/\X
is your file .ts or .js
m
Hey RP - I realised after posting that it was typescript, sorry for the bother. However I keep getting 'unaurthorised' when trying to make an API call to a route with verifysession (despite the user being logged in). Anything obvious i can check?
r
Can you enable debug logging and show me the output when making that call?
m
I tried passing
verifySession({sessionRequired: false})
here is the output
This is the code
I think there's something wrong on the front end, as I can't access pages inside of
<EmailPasswordAuth>
tags
Interestingly,
doesSessionExist()
reports true
r
You don’t need to call getSession again
You can just do req.session
And if your api is not getting called at all, please enable debug logs and then show me the output logs when you call the api
m
Morning @rp , first I wanted to thank you for your ongoing support, it's very kind. Second I want to point out that I'm just a student so I understand if you need to spend your time on other more important support cases. I get the response 'unauthorised' when ever I try to access an API on the front end that has verifysession() on it despite the user being logged in. I am not sure how to enable debug logging in react or for supertokens. I googled it but wasn't sure what you were looking for.
r
You can look for the section “troubleshooting” in our docs
That will show you how to enable debug logging
m
Ah thank you - here is the output (happy to paste the code if that would help)
This is the call from the frontend
r
You need to make a call to localhost:3001 instead of 127.0.0.1:3001
m
That worked 🤦‍♂️
I even wrote origin: "http://localhost:3000", in the backend! What an idiot I am
r
Hehe. Don’t worry about it.
m
In a perhaps unrelated problem, nothing inside of will load despite being logged in
It works if I use but obviously that's not what we want!
r
Any console error?
m
I am a fool! I must have been tired because I had wrapped the entire root in the tags not just the element, its working now. Sorry to bother you @rp !
Thank you again 👏
r
Happy to help 🙂
5 Views