#Guys help me how to append file for formik and axios
7 messages · Page 1 of 1 (latest)
const formik = useFormik({
initialValues: {
title: "",
description: "",
status: 1,
expire_at: "",
images: null,
},
onSubmit: async (
{ title, description, status, expire_at, images },
actions
) => {
const formData = new FormData();
formData.append("images", images[0]);
formData.append("title", title);
formData.append("description", description);
formData.append("status", status);
formData.append("expire_at", expire_at);
await axios.post(
${process.env.NEXT_PUBLIC_BACKEND}/classified,
formData,
{
headers: {
Authorization: Bearer ${token},
},
}
);
actions.resetForm();
setSelectedFile([]);
},
});
@sudden marten i am getting this response from backend ['The images must be an array.'] what can be done?