HELP I want to send array of Object has files to FormData, using Zod and react hook form
Unanswered
Australian Freshwater Crocodile posted this in #help-forum
Australian Freshwater CrocodileOP
this is my values
and i do this code but its not working because i have Array of object
values: {
body: string;
title: string;
checkIn: Date;
checkOut: Date;
guests: string;
pricePerNight: string;
galleryTour: {
titleGallery?: string | undefined;
imageGallery?: File | undefined;
}[];
feauturedImage?: File | undefined;
}and i do this code but its not working because i have Array of object
async function onSubmit(values: CreateTourValues) {
const formData = new FormData();
Object.entries(values).forEach(([key, value]) => {
if (value) {
formData.append(key, value);
}
});
}