Programming Tips - javaScript: serialize a FormData object

Date: 2021jan8 Language: javaScript Q. javaScript: serialize a FormData object A. Use URLSearchParams to convert to application/x-www-form-urlencoded
const formdata = new FormData(event.target); formdata.append('userid', 'jeff'); formdata.append('password', 'amazon');
const query = new URLSearchParams(formdata).toString(); console.log('query=' + query);
Will log
userid=jeff&password=amazon
You cannot do this for files in a FormData.