Adding values to FormData - javascript
Transformation rules

Especially useful if there are many fields and each needs a unique rule.

const dateToUTCString = d =&gt; new Date(d).toUTCString();

const DataTransformer = {
  createdDate: dateToUTCString,
  expirationDate: dateToUTCString,
};

// [...]

for (const [key, calue] of Object.entries(product)) {
  const transform = DataTransformer[key];
  formData.append(key, transform ? transform(value) : value);
}