How can one take the information of a URL?
I want to use the appended information on this URL http://localhost:3000/transaction?transactionId=72U8ALPE in a fetch API.
I am trying to take the value 72U8ALPE and save it to state or as a variable. Then use if on the URL I will use on a fetch request. For example
https://google.com/${the-url-last-part-saved-as-variable-or-in-state}
>Solution :
You can get the query parameters from the URL object.
This could look something like this:
let currentUrl = new URL(window.location);
let transactionId = currentUrl.searchParams.get('transactionId');
You can then use the variable to append to your HTTP request.