I am trying to send an array of type String and a png file using multipart/form data. I receive my image file and I receive my data via req.body. However the array is of type String, as expected. How do I parse this into an array?
You could use JSON.parse
to convert string to array.
let tattooGroups= `["Women", "Unisex"]`;
console.log("Without JSON.parse -> ", typeof tattooGroups);
console.log("With JSON.parse -> ", typeof JSON.parse(tattooGroups));
console.log("With JSON.parse, Is Array -> ", Array.isArray(JSON.parse(tattooGroups)));
console.log(JSON.parse(tattooGroups));