0

I use the Firebase SDK in my React-App. If a user wants to reset his password, he will be redirected to a page within my app. Firebase requires the code to be inserted in the URL for password reset.

The Code will be saved in this.props.location.search When i log this prop, i get his:

?mode=resetPassword&oobCode=3ckTC8-xBAzTUCbrWQCrg4i0kD6F2_wOmuaeiHLsQH8AAAFmERVurw&apiKey=AIzaSyDC3GXJ2rcONeBYTu9FBjZEfJbEsaJMWNo&lang=en

How can i get only the Code from this URL Parameters?

Thanks for your answer and for your help

Niklas
  • 1,638
  • 4
  • 19
  • 48
  • The problem has nothing to do with firebase or ReactJS, you will find answers in the linked duplicate ^ –  Sep 25 '18 at 14:28
  • I think OP is looking for [_this_](https://stackoverflow.com/questions/35352638/how-to-get-parameter-value-from-query-string) – Rayon Sep 25 '18 at 14:34

1 Answers1

0

use any dummy site name to construct URL and do this,

let params = (new URL(`http://dummy.com${this.props.location.search}`)).searchParams;
let code = params.get("oobCode")

more info, here

Chaitanya Mankala
  • 1,594
  • 17
  • 24