Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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]) ;
}
Comment

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);
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: electron how to setup preload.js 
Javascript :: add array to array javascript 
Javascript :: get domain name with regex 
Javascript :: dom element set id 
Javascript :: classiceditor is not defined using npm 
Javascript :: email regular expression javascript 
Javascript :: remove all duplicates from an array 
Javascript :: node.js express 
Javascript :: how to show progress on ajax call 
Javascript :: kebab case javascript 
Javascript :: how to convert a queryset into json string 
Javascript :: convert currency to string javascript 
Javascript :: js array includes 
Javascript :: create new element 
Javascript :: push data to firebase javascript 
Javascript :: string literal javascript 
Javascript :: mongodb sort 
Javascript :: cypress check element have attribute 
Javascript :: form data object 
Javascript :: promise all then 
Javascript :: react dont render component until loaded 
Javascript :: mongodb mongoose push into nested array 
Javascript :: shadowcolor liners in react native 
Javascript :: html onchange call js function 
Javascript :: link to another page and achor react 
Javascript :: how to make fake binary 
Javascript :: field array using useFormik 
Javascript :: select field in react native 
Javascript :: mongoose delete 
Javascript :: extends in javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =