I'm currently working with Vue3 and axios to submit a form using FormData
. However, I am facing an issue where the form data is empty and not being passed.
{"formData":{}}
Here's my code snippet:
const formData= new FormData();
formData.set("name", name);
axios.post("postform", formData);
I have also attempted the following approaches:
formData.set("name", "John Doe");
axios.post("postform", formData);
and this:
formData.append("name", "John Doe");
axios.post("postform", formData);
Unfortunately, none of these methods have worked for me. There are no errors displayed, but the form data remains empty.
In my PHP code, I retrieve the data like this:
echo $request->input("name");
Therefore, my main inquiry is:
How can I successfully post data utilizing FormData
?