I'm adding data to the formData by appending each item from my javascript object and it looks like this:
let formData = new FormData();
formData.append('File', document.file);
product = {
...values,
productType: productT,
};
const DataTransformer = {
createdDate: howtoreadvaluefrom...values, // How can I read value createdDate from ...values
expirationDate: howtoreadvaluefrom...values, // How can I read value expirationDate from ...values
};
for (var key in product) {
if (key != 'createdDate' && key != 'expirationDate') {
formData.append(key, product[key]);
} else {
formData.append(key, new Date(product[key]).toUTCString());
}
}
await createproduct(formData);
As you can see there is DataTransformer
variable and I would like to populate those two props from ...values
but I'm not sure what's proper way to do it..
Thanks a lot
Cheers