Get Parameter from URL

I am trying to set up Magic Link through Xano and SendGrid. I’ve got everything working but I have to get one final piece of the puzzle set up. I need to be able to extract the magic token from the user’s URL, and then can exchange that for an auth token with Xano.

Here’s an example of what the URL looks like:
https://www.goaloe.app/magic-link-auth?token=EBhgaAGERk123akadASFDKJWL.KAJAFS834;LJ43T9KaADFAS;A;-0A;KLSDFJC9ADEFNDSA;a0d9.aksfdASDJkA;SLDJKN32ASD.DZTCo1Tm2W3bBwbxOOoLWrtID11qj_fSUD0LcM-BlikKJ;A3NADFAAN44kDFNDSJNQKNKNnadsJEW443Kndasfl;khG47xc4._kafdsKASDFNkNDFKJkan;9834t7JAFDkd3KDk3KANnRnALPHs

Here’s the javascript code I have tried to get the token, but it’s not working:
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const token= urlParams.get(‘token’)
return token

I’d love some help! Thank you!

const urlParams = new URLSearchParams(location.search);
urlParams.get(‘token’);

You can just dump the whole url into the URLSearchParams constructor.

boom.

You can also create a query variable that have the same name as the key you want to target in the URL. WeWeb will fill the value with the value from the URL.

2 Likes

Wow, that’s great! I’m so glad I know that now.

I was able to set up magic link with Xano and am happy to share my work if anyone else is looking to do the same.

2 Likes