Open xgqfrms opened 3 years ago
🎉 awesome vanilla js solution
const queryString = new URLSearchParams(); queryString.append('param1', 'value1'); queryString.append('param2', 'value2'); axios.post('/foo', queryString); // test for(const item of queryString){ console.log(item); } /* ["param1", "value1"] ["param2", "value2"] */
const formData = new FormData(); formData.append('param1', 'value1'); formData.append('param2', 'value2'); axios.post('/foo', formData); // test for(const item of formData){ console.log(item); } /* ["param1", "value1"] ["param2", "value2"] */
axios.post & x-www-form-urlencoded & multipart/form-data All In One
URLSearchParams
FormData