Sha256: 459bb2fcac7a58853f533d36a227e2583fd774153bd75c1c866ef654294dade8
Contents?: true
Size: 569 Bytes
Versions: 13
Compression:
Stored size: 569 Bytes
Contents
// Turns an Object into FormData. Note that a nested array will come out as a hash with numeric keys // and will need to be handled accordingly server-side. export function buildFormData(formData, data, parentKey) { if (data && typeof data === 'object' && !(data instanceof Date) && !(data instanceof File) && !(data instanceof Blob)) { Object.keys(data).forEach(key => { buildFormData(formData, data[key], parentKey ? `${parentKey}[${key}]` : key); }); } else { const value = data == null ? '' : data; formData.append(parentKey, value); } }
Version data entries
13 entries across 13 versions & 2 rubygems