Created
June 7, 2020 12:44
-
-
Save domosedov/692287f1aaa766ca32d4e5e346666dc8 to your computer and use it in GitHub Desktop.
Convert FormData to Query String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handleSubmit(event) { | |
event.preventDefault(); | |
const formData = new FormData(event.target); | |
const data = [...formData.entries()]; | |
const asString = data | |
.map(x => `${encodeURIComponent(x[0])}=${encodeURIComponent(x[1])}`) | |
.join('&'); | |
console.log(asString); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment