A
A
Alexander Osadchy2021-07-19 19:11:57
React
Alexander Osadchy, 2021-07-19 19:11:57

How to read data from a link into a form?

Hello!

Can you please tell me how can I read the data from the link into the form?

Links like this:

site .com/signup?email=user%40mail.com&phone=380989035745&date=19911225&offer=1&lang=ua&country=ua


It leads to the registration page, and the data transferred to the links must be placed in the form:

Email: [email protected]
Phone: 380989035745
Birthday: 1991.12.25
Country: Ukraine Does

anyone have examples of implementation? .. thanks to all those who are not indifferent!)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2021-07-19
@slide13

If IE is not needed, then you can use URLSearchParams

let url = 'email=user%40mail.com&phone=380989035745&date=19911225&offer=1&lang=ua&country=ua'
console.log([...new URLSearchParams(url).entries()].reduce((query, [key, value]) => Object.assign(query, {[key]: value}), {}))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question