Answers for "formdata array of objects"

0

formdata array of objects

const formData = new FormData();
for (let key in form) {
    Array.isArray(form[key])
        ? form[key].forEach(value => formData.append(key + '[]', value))
        : formData.append(key, form[key]) ;
}
Posted by: Guest on August-25-2021
-1

formdata array of objects

function createFormData(formData, key, data) {
    if (data === Object(data) || Array.isArray(data)) {
        for (var i in data) {
            createFormData(formData, key + '[' + i + ']', data[i]);
        }
    } else {
        formData.append(key, data);
    }
}
Posted by: Guest on August-25-2021

Code answers related to "formdata array of objects"

Code answers related to "Javascript"

Browse Popular Code Answers by Language